grafana/pkg/services/serviceaccounts/models.go
J Guerreiro 2aeae69a16
Service Accounts: Display name to ID (#46258)
* ServiceAccounts: modernize SA creation interface

* ServiceAccounts: improve service account ID generation

* ServiceAccounts: remove unused method

* ServiceAccounts: Make SA ID display name dependent

* ServiceAccounts: Add tests for Service Account creation

* trim trailing whitespace

* Update pkg/services/serviceaccounts/api/api.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>

* Update pkg/services/serviceaccounts/api/api.go

Co-authored-by: Ieva <ieva.vasiljeva@grafana.com>
2022-03-08 12:07:58 +01:00

56 lines
1.8 KiB
Go

package serviceaccounts
import (
"time"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/services/accesscontrol"
)
var (
ScopeAll = "serviceaccounts:*"
ScopeID = accesscontrol.Scope("serviceaccounts", "id", accesscontrol.Parameter(":serviceAccountId"))
)
const (
ActionRead = "serviceaccounts:read"
ActionWrite = "serviceaccounts:write"
ActionCreate = "serviceaccounts:create"
ActionDelete = "serviceaccounts:delete"
)
type ServiceAccount struct {
Id int64
}
type UpdateServiceAccountForm struct {
Name *string `json:"name"`
Role *models.RoleType `json:"role"`
IsDisabled *bool `json:"isDisabled"`
}
type ServiceAccountDTO struct {
Id int64 `json:"id" xorm:"user_id"`
Name string `json:"name" xorm:"name"`
Login string `json:"login" xorm:"login"`
OrgId int64 `json:"orgId" xorm:"org_id"`
Role string `json:"role" xorm:"role"`
Tokens int64 `json:"tokens"`
AvatarUrl string `json:"avatarUrl"`
AccessControl map[string]bool `json:"accessControl,omitempty"`
}
type ServiceAccountProfileDTO struct {
Id int64 `json:"id" xorm:"user_id"`
Name string `json:"name" xorm:"name"`
Login string `json:"login" xorm:"login"`
OrgId int64 `json:"orgId" xorm:"org_id"`
IsDisabled bool `json:"isDisabled" xorm:"is_disabled"`
Created time.Time `json:"createdAt" xorm:"created"`
Updated time.Time `json:"updatedAt" xorm:"updated"`
AvatarUrl string `json:"avatarUrl" xorm:"-"`
Role string `json:"role" xorm:"role"`
Teams []string `json:"teams" xorm:"-"`
AccessControl map[string]bool `json:"accessControl,omitempty" xorm:"-"`
}