mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -06:00
6afad51761
* Move SignedInUser to user service and RoleType and Roles to org * Use go naming convention for roles * Fix some imports and leftovers * Fix ldap debug test * Fix lint * Fix lint 2 * Fix lint 3 * Fix type and not needed conversion * Clean up messages in api tests * Clean up api tests 2
108 lines
2.6 KiB
Go
108 lines
2.6 KiB
Go
package models
|
|
|
|
import (
|
|
"errors"
|
|
"time"
|
|
|
|
"github.com/grafana/grafana/pkg/services/user"
|
|
)
|
|
|
|
// 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")
|
|
)
|
|
|
|
// Team model
|
|
type Team struct {
|
|
Id int64 `json:"id"`
|
|
OrgId int64 `json:"orgId"`
|
|
Name string `json:"name"`
|
|
Email string `json:"email"`
|
|
|
|
Created time.Time `json:"created"`
|
|
Updated time.Time `json:"updated"`
|
|
}
|
|
|
|
// ---------------------
|
|
// COMMANDS
|
|
|
|
type CreateTeamCommand struct {
|
|
Name string `json:"name" binding:"Required"`
|
|
Email string `json:"email"`
|
|
OrgId int64 `json:"-"`
|
|
|
|
Result Team `json:"-"`
|
|
}
|
|
|
|
type UpdateTeamCommand struct {
|
|
Id int64
|
|
Name string
|
|
Email string
|
|
OrgId int64 `json:"-"`
|
|
}
|
|
|
|
type DeleteTeamCommand struct {
|
|
OrgId int64
|
|
Id int64
|
|
}
|
|
|
|
type GetTeamByIdQuery struct {
|
|
OrgId int64
|
|
Id int64
|
|
SignedInUser *user.SignedInUser
|
|
HiddenUsers map[string]struct{}
|
|
Result *TeamDTO
|
|
UserIdFilter int64
|
|
}
|
|
|
|
// FilterIgnoreUser is used in a get / search teams query when the caller does not want to filter teams by user ID / membership
|
|
const FilterIgnoreUser int64 = 0
|
|
|
|
type GetTeamsByUserQuery struct {
|
|
OrgId int64
|
|
UserId int64 `json:"userId"`
|
|
Result []*TeamDTO `json:"teams"`
|
|
SignedInUser *user.SignedInUser
|
|
}
|
|
|
|
type SearchTeamsQuery struct {
|
|
Query string
|
|
Name string
|
|
Limit int
|
|
Page int
|
|
OrgId int64
|
|
UserIdFilter int64
|
|
SignedInUser *user.SignedInUser
|
|
HiddenUsers map[string]struct{}
|
|
|
|
Result SearchTeamQueryResult
|
|
}
|
|
|
|
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"`
|
|
AccessControl map[string]bool `json:"accessControl"`
|
|
}
|
|
|
|
type SearchTeamQueryResult struct {
|
|
TotalCount int64 `json:"totalCount"`
|
|
Teams []*TeamDTO `json:"teams"`
|
|
Page int `json:"page"`
|
|
PerPage int `json:"perPage"`
|
|
}
|
|
|
|
type IsAdminOfTeamsQuery struct {
|
|
SignedInUser *user.SignedInUser
|
|
Result bool
|
|
}
|