grafana/pkg/models/team.go

100 lines
2.2 KiB
Go
Raw Normal View History

package models
import (
"errors"
"time"
)
// Typed errors
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")
)
2017-12-08 09:25:45 -06:00
// Team model
type Team struct {
2017-04-09 18:24:16 -05:00
Id int64 `json:"id"`
OrgId int64 `json:"orgId"`
Name string `json:"name"`
Email string `json:"email"`
2017-04-09 18:24:16 -05:00
Created time.Time `json:"created"`
Updated time.Time `json:"updated"`
}
// ---------------------
// COMMANDS
2017-12-08 09:25:45 -06:00
type CreateTeamCommand struct {
Name string `json:"name" binding:"Required"`
Email string `json:"email"`
2017-04-09 18:24:16 -05:00
OrgId int64 `json:"-"`
2017-12-08 09:25:45 -06:00
Result Team `json:"-"`
}
2017-12-08 09:25:45 -06:00
type UpdateTeamCommand struct {
Id int64
Name string
Email string
OrgId int64 `json:"-"`
2017-04-18 08:01:05 -05:00
}
2017-12-08 09:25:45 -06:00
type DeleteTeamCommand struct {
OrgId int64
Id int64
}
2017-12-08 09:25:45 -06:00
type GetTeamByIdQuery struct {
OrgId int64
Id int64
SignedInUser *SignedInUser
HiddenUsers map[string]struct{}
Result *TeamDTO
}
2017-12-08 09:25:45 -06:00
type GetTeamsByUserQuery struct {
OrgId int64
UserId int64 `json:"userId"`
Result []*TeamDTO `json:"teams"`
2017-05-22 03:33:17 -05:00
}
2017-12-08 09:25:45 -06:00
type SearchTeamsQuery struct {
Query string
Name string
Limit int
Page int
OrgId int64
UserIdFilter int64
SignedInUser *SignedInUser
HiddenUsers map[string]struct{}
2017-12-08 09:25:45 -06:00
Result SearchTeamQueryResult
2017-04-09 18:24:16 -05:00
}
type TeamDTO struct {
Id int64 `json:"id"`
OrgId int64 `json:"orgId"`
Name string `json:"name"`
Email string `json:"email"`
AvatarUrl string `json:"avatarUrl"`
MemberCount int64 `json:"memberCount"`
Permission PermissionType `json:"permission"`
}
2017-12-08 09:25:45 -06:00
type SearchTeamQueryResult struct {
TotalCount int64 `json:"totalCount"`
Teams []*TeamDTO `json:"teams"`
Page int `json:"page"`
PerPage int `json:"perPage"`
}
type IsAdminOfTeamsQuery struct {
SignedInUser *SignedInUser
Result bool
}