team

package
v0.0.0-testrgm6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const FilterIgnoreUser int64 = 0

FilterIgnoreUser is used in a get / search teams query when the caller does not want to filter teams by user ID / membership

Variables

View Source
var (
	ErrTeamNotFound                         = errors.New("team not found")
	ErrTeamNameTaken                        = errors.New("team name is taken")
	ErrTeamMemberNotFound                   = errors.New("team member not found")
	ErrLastTeamAdmin                        = errors.New("not allowed to remove last admin")
	ErrNotAllowedToUpdateTeam               = errors.New("user not allowed to update team")
	ErrNotAllowedToUpdateTeamInDifferentOrg = errors.New("user not allowed to update team in another org")

	ErrTeamMemberAlreadyAdded = errors.New("user is already added to this team")
)

Typed errors

Functions

This section is empty.

Types

type AddTeamMemberCommand

type AddTeamMemberCommand struct {
	UserID     int64                     `json:"userId" binding:"Required"`
	OrgID      int64                     `json:"-"`
	TeamID     int64                     `json:"-"`
	External   bool                      `json:"-"`
	Permission dashboards.PermissionType `json:"-"`
}

type CreateTeamCommand

type CreateTeamCommand struct {
	Name  string `json:"name" binding:"Required"`
	Email string `json:"email"`
	OrgID int64  `json:"-"`
}

type DeleteTeamCommand

type DeleteTeamCommand struct {
	OrgID int64
	ID    int64
}

type GetTeamByIDQuery

type GetTeamByIDQuery struct {
	OrgID        int64
	ID           int64
	SignedInUser *user.SignedInUser
	HiddenUsers  map[string]struct{}
}

type GetTeamMembersQuery

type GetTeamMembersQuery struct {
	OrgID        int64
	TeamID       int64
	TeamUID      string
	UserID       int64
	External     bool
	SignedInUser *user.SignedInUser
}

type GetTeamsByUserQuery

type GetTeamsByUserQuery struct {
	OrgID        int64
	UserID       int64 `json:"userId"`
	SignedInUser *user.SignedInUser
}

type RemoveTeamMemberCommand

type RemoveTeamMemberCommand struct {
	OrgID  int64 `json:"-"`
	UserID int64
	TeamID int64
}

type SearchTeamQueryResult

type SearchTeamQueryResult struct {
	TotalCount int64      `json:"totalCount"`
	Teams      []*TeamDTO `json:"teams"`
	Page       int        `json:"page"`
	PerPage    int        `json:"perPage"`
}

type SearchTeamsQuery

type SearchTeamsQuery struct {
	Query        string
	Name         string
	Limit        int
	Page         int
	OrgID        int64 `xorm:"org_id"`
	SignedInUser *user.SignedInUser
	HiddenUsers  map[string]struct{}
}

type Service

type Service interface {
	CreateTeam(name, email string, orgID int64) (Team, error)
	UpdateTeam(ctx context.Context, cmd *UpdateTeamCommand) error
	DeleteTeam(ctx context.Context, cmd *DeleteTeamCommand) error
	SearchTeams(ctx context.Context, query *SearchTeamsQuery) (SearchTeamQueryResult, error)
	GetTeamByID(ctx context.Context, query *GetTeamByIDQuery) (*TeamDTO, error)
	GetTeamsByUser(ctx context.Context, query *GetTeamsByUserQuery) ([]*TeamDTO, error)
	AddTeamMember(userID, orgID, teamID int64, isExternal bool, permission dashboards.PermissionType) error
	UpdateTeamMember(ctx context.Context, cmd *UpdateTeamMemberCommand) error
	IsTeamMember(orgId int64, teamId int64, userId int64) (bool, error)
	RemoveTeamMember(ctx context.Context, cmd *RemoveTeamMemberCommand) error
	RemoveUsersMemberships(tx context.Context, userID int64) error
	GetUserTeamMemberships(ctx context.Context, orgID, userID int64, external bool) ([]*TeamMemberDTO, error)
	GetTeamMembers(ctx context.Context, query *GetTeamMembersQuery) ([]*TeamMemberDTO, error)
}

type Team

type Team struct {
	ID    int64  `json:"id" xorm:"pk autoincr 'id'"`
	UID   string `json:"uid" xorm:"uid"`
	OrgID int64  `json:"orgId" xorm:"org_id"`
	Name  string `json:"name"`
	Email string `json:"email"`

	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Team model

func (*Team) ToResource

func (t *Team) ToResource() team.K8sResource

type TeamDTO

type TeamDTO struct {
	ID            int64                     `json:"id" xorm:"id"`
	UID           string                    `json:"uid" xorm:"uid"`
	OrgID         int64                     `json:"orgId" xorm:"org_id"`
	Name          string                    `json:"name"`
	Email         string                    `json:"email"`
	AvatarURL     string                    `json:"avatarUrl"`
	MemberCount   int64                     `json:"memberCount"`
	Permission    dashboards.PermissionType `json:"permission"`
	AccessControl map[string]bool           `json:"accessControl"`
}

type TeamMember

type TeamMember struct {
	ID         int64 `xorm:"pk autoincr 'id'"`
	OrgID      int64 `xorm:"org_id"`
	TeamID     int64 `xorm:"team_id"`
	UserID     int64 `xorm:"user_id"`
	External   bool  // Signals that the membership has been created by an external systems, such as LDAP
	Permission dashboards.PermissionType

	Created time.Time
	Updated time.Time
}

TeamMember model

type TeamMemberDTO

type TeamMemberDTO struct {
	OrgID      int64                     `json:"orgId" xorm:"org_id"`
	TeamID     int64                     `json:"teamId" xorm:"team_id"`
	TeamUID    string                    `json:"teamUID" xorm:"uid"`
	UserID     int64                     `json:"userId" xorm:"user_id"`
	External   bool                      `json:"-"`
	AuthModule string                    `json:"auth_module"`
	Email      string                    `json:"email"`
	Name       string                    `json:"name"`
	Login      string                    `json:"login"`
	AvatarURL  string                    `json:"avatarUrl" xorm:"avatar_url"`
	Labels     []string                  `json:"labels"`
	Permission dashboards.PermissionType `json:"permission"`
}

type UpdateTeamCommand

type UpdateTeamCommand struct {
	ID    int64
	Name  string
	Email string
	OrgID int64 `json:"-"`
}

type UpdateTeamMemberCommand

type UpdateTeamMemberCommand struct {
	UserID     int64                     `json:"-"`
	OrgID      int64                     `json:"-"`
	TeamID     int64                     `json:"-"`
	Permission dashboards.PermissionType `json:"permission"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL