grafana/pkg/services/dashboards/dashboardaccess/dashboard_access.go

33 lines
1.1 KiB
Go
Raw Normal View History

package dashboardaccess
2017-06-09 14:56:13 -05:00
import (
"errors"
)
type PermissionType int
const (
2017-06-09 14:56:13 -05:00
PERMISSION_VIEW PermissionType = 1 << iota
PERMISSION_EDIT
2017-06-20 16:18:20 -05:00
PERMISSION_ADMIN
)
func (p PermissionType) String() string {
names := map[int]string{
2017-06-20 16:18:20 -05:00
int(PERMISSION_VIEW): "View",
int(PERMISSION_EDIT): "Edit",
int(PERMISSION_ADMIN): "Admin",
}
return names[int(p)]
}
// Typed errors
2017-06-09 14:56:13 -05:00
var (
ErrDashboardACLInfoMissing = errors.New("user id and team id cannot both be empty for a dashboard permission")
ErrDashboardPermissionDashboardEmpty = errors.New("dashboard id must be greater than zero for a dashboard permission")
ErrFolderACLInfoMissing = errors.New("user id and team id cannot both be empty for a folder permission")
ErrFolderPermissionFolderEmpty = errors.New("folder id must be greater than zero for a folder permission")
ErrPermissionsWithRoleNotAllowed = errors.New("permissions cannot have both a user and team")
ErrPermissionsWithUserAndTeamNotAllowed = errors.New("team and user permissions cannot have an associated role")
2017-06-09 14:56:13 -05:00
)