dashboards

package
v0.0.0-...-fb7f86c Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScopeFoldersRoot   = "folders"
	ScopeFoldersPrefix = "folders:uid:"

	ActionFoldersCreate           = "folders:create"
	ActionFoldersRead             = "folders:read"
	ActionFoldersWrite            = "folders:write"
	ActionFoldersDelete           = "folders:delete"
	ActionFoldersPermissionsRead  = "folders.permissions:read"
	ActionFoldersPermissionsWrite = "folders.permissions:write"

	ScopeDashboardsRoot   = "dashboards"
	ScopeDashboardsPrefix = "dashboards:uid:"

	ActionDashboardsCreate           = "dashboards:create"
	ActionDashboardsRead             = "dashboards:read"
	ActionDashboardsWrite            = "dashboards:write"
	ActionDashboardsDelete           = "dashboards:delete"
	ActionDashboardsPermissionsRead  = "dashboards.permissions:read"
	ActionDashboardsPermissionsWrite = "dashboards.permissions:write"
	ActionDashboardsPublicWrite      = "dashboards.public:write"
)
View Source
const (
	DashTypeDB       = "db"
	DashTypeSnapshot = "snapshot"
)
View Source
const (
	QuotaTargetSrv quota.TargetSrv = "dashboard"
	QuotaTarget    quota.Target    = "dashboard"
)
View Source
const RootFolderName = "General"

Variables

View Source
var (
	ScopeFoldersProvider    = ac.NewScopeProvider(ScopeFoldersRoot)
	ScopeFoldersAll         = ScopeFoldersProvider.GetResourceAllScope()
	ScopeDashboardsProvider = ac.NewScopeProvider(ScopeDashboardsRoot)
	ScopeDashboardsAll      = ScopeDashboardsProvider.GetResourceAllScope()
)
View Source
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")
)

Typed errors

View Source
var (
	ErrDashboardNotFound = DashboardErr{
		Reason:     "Dashboard not found",
		StatusCode: 404,
		Status:     "not-found",
	}
	ErrDashboardCorrupt = DashboardErr{
		Reason:     "Dashboard data is missing or corrupt",
		StatusCode: 500,
		Status:     "not-found",
	}
	ErrDashboardPanelNotFound = DashboardErr{
		Reason:     "Dashboard panel not found",
		StatusCode: 404,
		Status:     "not-found",
	}
	ErrDashboardFolderNotFound = DashboardErr{
		Reason:     "Folder not found",
		StatusCode: 404,
	}
	ErrDashboardWithSameUIDExists = DashboardErr{
		Reason:     "A dashboard with the same uid already exists",
		StatusCode: 400,
	}
	ErrDashboardWithSameNameInFolderExists = DashboardErr{
		Reason:     "A dashboard with the same name in the folder already exists",
		StatusCode: 412,
		Status:     "name-exists",
	}
	ErrDashboardVersionMismatch = DashboardErr{
		Reason:     "The dashboard has been changed by someone else",
		StatusCode: 412,
		Status:     "version-mismatch",
	}
	ErrDashboardTitleEmpty = DashboardErr{
		Reason:     "Dashboard title cannot be empty",
		StatusCode: 400,
		Status:     "empty-name",
	}
	ErrDashboardFolderCannotHaveParent = DashboardErr{
		Reason:     "A Dashboard Folder cannot be added to another folder",
		StatusCode: 400,
	}
	ErrDashboardsWithSameSlugExists = DashboardErr{
		Reason:     "Multiple dashboards with the same slug exists",
		StatusCode: 412,
	}
	ErrDashboardTypeMismatch = DashboardErr{
		Reason:     "Dashboard cannot be changed to a folder",
		StatusCode: 400,
	}
	ErrDashboardFolderWithSameNameAsDashboard = DashboardErr{
		Reason:     "Folder name cannot be the same as one of its dashboards",
		StatusCode: 400,
	}
	ErrDashboardWithSameNameAsFolder = DashboardErr{
		Reason:     "Dashboard name cannot be the same as folder",
		StatusCode: 400,
		Status:     "name-match",
	}
	ErrDashboardFolderNameExists = DashboardErr{
		Reason:     "A folder with that name already exists",
		StatusCode: 400,
	}
	ErrDashboardUpdateAccessDenied = DashboardErr{
		Reason:     "Access denied to save dashboard",
		StatusCode: 403,
	}
	ErrDashboardInvalidUid = DashboardErr{
		Reason:     "uid contains illegal characters",
		StatusCode: 400,
	}
	ErrDashboardUidTooLong = DashboardErr{
		Reason:     "uid too long, max 40 characters",
		StatusCode: 400,
	}
	ErrDashboardCannotSaveProvisionedDashboard = DashboardErr{
		Reason:     "Cannot save provisioned dashboard",
		StatusCode: 400,
	}
	ErrDashboardRefreshIntervalTooShort = DashboardErr{
		Reason:     "Dashboard refresh interval is too low",
		StatusCode: 400,
	}
	ErrDashboardCannotDeleteProvisionedDashboard = DashboardErr{
		Reason:     "provisioned dashboard cannot be deleted",
		StatusCode: 400,
	}
	ErrDashboardIdentifierNotSet = DashboardErr{
		Reason:     "Unique identifier needed to be able to get a dashboard",
		StatusCode: 400,
	}
	ErrDashboardIdentifierInvalid = DashboardErr{
		Reason:     "Dashboard ID not a number",
		StatusCode: 400,
	}
	ErrDashboardPanelIdentifierInvalid = DashboardErr{
		Reason:     "Dashboard panel ID not a number",
		StatusCode: 400,
	}
	ErrDashboardOrPanelIdentifierNotSet = DashboardErr{
		Reason:     "Unique identifier needed to be able to get a dashboard panel",
		StatusCode: 400,
	}
	ErrProvisionedDashboardNotFound = DashboardErr{
		Reason:     "Dashboard is not provisioned",
		StatusCode: 404,
		Status:     "not-found",
	}

	ErrFolderNotFound           = errors.New("folder not found")
	ErrFolderVersionMismatch    = errors.New("the folder has been changed by someone else")
	ErrFolderTitleEmpty         = errors.New("folder title cannot be empty")
	ErrFolderWithSameUIDExists  = errors.New("a folder/dashboard with the same uid already exists")
	ErrFolderInvalidUID         = errors.New("invalid uid for folder provided")
	ErrFolderSameNameExists     = errors.New("a folder or dashboard in the general folder with the same name already exists")
	ErrFolderAccessDenied       = errors.New("access denied to folder")
	ErrFolderContainsAlertRules = errors.New("folder contains alert rules")
)

Typed errors

Functions

func FromDashboard

func FromDashboard(dash *Dashboard) *folder.Folder

func GetDashboardFolderURL

func GetDashboardFolderURL(isFolder bool, uid string, slug string) string

GetDashboardFolderURL return the html url for a folder if it's folder, otherwise for a dashboard

func GetDashboardURL

func GetDashboardURL(uid string, slug string) string

GetDashboardURL returns the HTML url for a dashboard.

func GetFolderURL

func GetFolderURL(folderUID string, slug string) string

GetFolderURL returns the HTML url for a folder.

func GetFullDashboardURL

func GetFullDashboardURL(uid string, slug string) string

GetFullDashboardURL returns the full URL for a dashboard.

func GetInheritedScopes

func GetInheritedScopes(ctx context.Context, orgID int64, folderUID string, folderSvc folder.Service) ([]string, error)

func GetKioskModeDashboardURL

func GetKioskModeDashboardURL(uid string, slug string, theme models.Theme) string

GetKioskModeDashboardUrl returns the HTML url for a dashboard in kiosk mode.

func NewDashboardIDScopeResolver

func NewDashboardIDScopeResolver(folderDB folder.FolderStore, ds DashboardService, folderSvc folder.Service) (string, ac.ScopeAttributeResolver)

NewDashboardIDScopeResolver provides an ScopeAttributeResolver that is able to convert a scope prefixed with "dashboards:id:" into uid based scopes for both dashboard and folder

func NewDashboardUIDScopeResolver

func NewDashboardUIDScopeResolver(folderDB folder.FolderStore, ds DashboardService, folderSvc folder.Service) (string, ac.ScopeAttributeResolver)

NewDashboardUIDScopeResolver provides an ScopeAttributeResolver that is able to convert a scope prefixed with "dashboards:uid:" into uid based scopes for both dashboard and folder

func NewFolderIDScopeResolver

func NewFolderIDScopeResolver(folderDB folder.FolderStore, folderSvc folder.Service) (string, ac.ScopeAttributeResolver)

NewFolderIDScopeResolver provides an ScopeAttributeResolver that is able to convert a scope prefixed with "folders:id:" into an uid based scope.

func NewFolderNameScopeResolver

func NewFolderNameScopeResolver(folderDB folder.FolderStore, folderSvc folder.Service) (string, ac.ScopeAttributeResolver)

NewFolderNameScopeResolver provides an ScopeAttributeResolver that is able to convert a scope prefixed with "folders:name:" into an uid based scope.

func NewFolderUIDScopeResolver

func NewFolderUIDScopeResolver(folderSvc folder.Service) (string, ac.ScopeAttributeResolver)

NewFolderUIDScopeResolver provides an ScopeAttributeResolver that is able to convert a scope prefixed with "folders:uid:" into uid based scopes for folder and its parents

Types

type CountDashboardsInFolderQuery

type CountDashboardsInFolderQuery struct {
	FolderUID string
	OrgID     int64
}

type CountDashboardsInFolderRequest

type CountDashboardsInFolderRequest struct {
	FolderID int64
	OrgID    int64
}

TODO: CountDashboardsInFolderRequest is the request passed from the service to the store layer. The FolderID will be replaced with FolderUID when dashboards are updated with parent folder UIDs.

type Dashboard

type Dashboard struct {
	ID       int64  `xorm:"pk autoincr 'id'"`
	UID      string `xorm:"uid"`
	Slug     string
	OrgID    int64 `xorm:"org_id"`
	GnetID   int64 `xorm:"gnet_id"`
	Version  int
	PluginID string `xorm:"plugin_id"`

	Created time.Time
	Updated time.Time

	UpdatedBy int64
	CreatedBy int64
	FolderID  int64 `xorm:"folder_id"`
	IsFolder  bool
	HasACL    bool `xorm:"has_acl"`

	Title string
	Data  *simplejson.Json
}

Dashboard model

func NewDashboard

func NewDashboard(title string) *Dashboard

NewDashboard creates a new dashboard

func NewDashboardFolder

func NewDashboardFolder(title string) *Dashboard

NewDashboardFolder creates a new dashboard folder

func NewDashboardFromJson

func NewDashboardFromJson(data *simplejson.Json) *Dashboard

func (*Dashboard) GetTags

func (d *Dashboard) GetTags() []string

GetTags turns the tags in data json into go string array

func (*Dashboard) GetURL

func (d *Dashboard) GetURL() string

GetURL return the html url for a folder if it's folder, otherwise for a dashboard

func (*Dashboard) SetID

func (d *Dashboard) SetID(id int64)

func (*Dashboard) SetUID

func (d *Dashboard) SetUID(uid string)

func (*Dashboard) SetVersion

func (d *Dashboard) SetVersion(version int)

func (*Dashboard) ToResource

func (d *Dashboard) ToResource() kinds.GrafanaResource[simplejson.Json, interface{}]

func (*Dashboard) UpdateSlug

func (d *Dashboard) UpdateSlug()

UpdateSlug updates the slug

type DashboardACL

type DashboardACL struct {
	ID          int64 `xorm:"pk autoincr 'id'"`
	OrgID       int64 `xorm:"org_id"`
	DashboardID int64 `xorm:"dashboard_id"`

	UserID     int64         `xorm:"user_id"`
	TeamID     int64         `xorm:"team_id"`
	Role       *org.RoleType // pointer to be nullable
	Permission PermissionType

	Created time.Time
	Updated time.Time
}

Dashboard ACL model

func (DashboardACL) TableName

func (p DashboardACL) TableName() string

type DashboardACLInfoDTO

type DashboardACLInfoDTO struct {
	OrgID       int64  `json:"-" xorm:"org_id"`
	DashboardID int64  `json:"dashboardId,omitempty" xorm:"dashboard_id"`
	FolderID    int64  `json:"folderId,omitempty" xorm:"folder_id"`
	FolderUID   string `json:"folderUid,omitempty" xorm:"folder_uid"`

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

	UserID         int64          `json:"userId" xorm:"user_id"`
	UserLogin      string         `json:"userLogin"`
	UserEmail      string         `json:"userEmail"`
	UserAvatarURL  string         `json:"userAvatarUrl" xorm:"user_avatar_url"`
	TeamID         int64          `json:"teamId" xorm:"team_id"`
	TeamEmail      string         `json:"teamEmail"`
	TeamAvatarURL  string         `json:"teamAvatarUrl" xorm:"team_avatar_url"`
	Team           string         `json:"team"`
	Role           *org.RoleType  `json:"role,omitempty"`
	Permission     PermissionType `json:"permission"`
	PermissionName string         `json:"permissionName"`
	UID            string         `json:"uid" xorm:"uid"`
	Title          string         `json:"title"`
	Slug           string         `json:"slug"`
	IsFolder       bool           `json:"isFolder"`
	URL            string         `json:"url" xorm:"url"`
	Inherited      bool           `json:"inherited"`
}

func (*DashboardACLInfoDTO) IsDuplicateOf

func (dto *DashboardACLInfoDTO) IsDuplicateOf(other *DashboardACLInfoDTO) bool

IsDuplicateOf returns true if other item has same role, same user or same team

type DashboardErr

type DashboardErr struct {
	StatusCode int
	Status     string
	Reason     string
}

DashboardErr represents a dashboard error.

func (DashboardErr) Body

func (e DashboardErr) Body() util.DynMap

Body returns the error's response body, if applicable.

func (DashboardErr) Equal

func (e DashboardErr) Equal(o DashboardErr) bool

Equal returns whether equal to another DashboardErr.

func (DashboardErr) Error

func (e DashboardErr) Error() string

Error returns the error message.

type DashboardProvisioning

type DashboardProvisioning struct {
	ID          int64 `xorm:"pk autoincr 'id'"`
	DashboardID int64 `xorm:"dashboard_id"`
	Name        string
	ExternalID  string `xorm:"external_id"`
	CheckSum    string
	Updated     int64
}

type DashboardProvisioningService

type DashboardProvisioningService interface {
	DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *DeleteOrphanedProvisionedDashboardsCommand) error
	DeleteProvisionedDashboard(ctx context.Context, dashboardID int64, orgID int64) error
	GetProvisionedDashboardData(ctx context.Context, name string) ([]*DashboardProvisioning, error)
	GetProvisionedDashboardDataByDashboardID(ctx context.Context, dashboardID int64) (*DashboardProvisioning, error)
	GetProvisionedDashboardDataByDashboardUID(ctx context.Context, orgID int64, dashboardUID string) (*DashboardProvisioning, error)
	SaveFolderForProvisionedDashboards(context.Context, *SaveDashboardDTO) (*Dashboard, error)
	SaveProvisionedDashboard(ctx context.Context, dto *SaveDashboardDTO, provisioning *DashboardProvisioning) (*Dashboard, error)
	UnprovisionDashboard(ctx context.Context, dashboardID int64) error
}

DashboardProvisioningService is a service for operating on provisioned dashboards.

type DashboardRef

type DashboardRef struct {
	UID  string `xorm:"uid"`
	Slug string
}

type DashboardSearchProjection

type DashboardSearchProjection struct {
	ID          int64  `xorm:"id"`
	UID         string `xorm:"uid"`
	Title       string
	Slug        string
	Term        string
	IsFolder    bool
	FolderID    int64  `xorm:"folder_id"`
	FolderUID   string `xorm:"folder_uid"`
	FolderSlug  string
	FolderTitle string
	SortMeta    int64
}

type DashboardService

type DashboardService interface {
	BuildSaveDashboardCommand(ctx context.Context, dto *SaveDashboardDTO, shouldValidateAlerts bool, validateProvisionedDashboard bool) (*SaveDashboardCommand, error)
	DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error
	FindDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) ([]DashboardSearchProjection, error)
	GetDashboard(ctx context.Context, query *GetDashboardQuery) (*Dashboard, error)
	GetDashboardACLInfoList(ctx context.Context, query *GetDashboardACLInfoListQuery) ([]*DashboardACLInfoDTO, error)
	GetDashboards(ctx context.Context, query *GetDashboardsQuery) ([]*Dashboard, error)
	GetDashboardTags(ctx context.Context, query *GetDashboardTagsQuery) ([]*DashboardTagCloudItem, error)
	GetDashboardUIDByID(ctx context.Context, query *GetDashboardRefByIDQuery) (*DashboardRef, error)
	ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*Dashboard, error)
	MakeUserAdmin(ctx context.Context, orgID int64, userID, dashboardID int64, setViewAndEditPermissions bool) error
	SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*Dashboard, error)
	SearchDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) (model.HitList, error)
	UpdateDashboardACL(ctx context.Context, uid int64, items []*DashboardACL) error
	DeleteACLByUser(ctx context.Context, userID int64) error
	CountInFolder(ctx context.Context, orgID int64, folderUID string, user *user.SignedInUser) (int64, error)
}

DashboardService is a service for operating on dashboards.

type DashboardTagCloudItem

type DashboardTagCloudItem struct {
	Term  string `json:"term"`
	Count int    `json:"count"`
}

type DeleteDashboardCommand

type DeleteDashboardCommand struct {
	ID                     int64
	OrgID                  int64
	ForceDeleteFolderRules bool
}

type DeleteDashboardsInFolderRequest

type DeleteDashboardsInFolderRequest struct {
	FolderUID string
	OrgID     int64
}

type DeleteOrphanedProvisionedDashboardsCommand

type DeleteOrphanedProvisionedDashboardsCommand struct {
	ReaderNames []string
}

type FakeDashboardProvisioning

type FakeDashboardProvisioning struct {
	mock.Mock
}

FakeDashboardProvisioning is an autogenerated mock type for the DashboardProvisioningService type

func NewFakeDashboardProvisioning

func NewFakeDashboardProvisioning(t mockConstructorTestingTNewFakeDashboardProvisioning) *FakeDashboardProvisioning

NewFakeDashboardProvisioning creates a new instance of FakeDashboardProvisioning. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*FakeDashboardProvisioning) DeleteOrphanedProvisionedDashboards

func (_m *FakeDashboardProvisioning) DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *DeleteOrphanedProvisionedDashboardsCommand) error

DeleteOrphanedProvisionedDashboards provides a mock function with given fields: ctx, cmd

func (*FakeDashboardProvisioning) DeleteProvisionedDashboard

func (_m *FakeDashboardProvisioning) DeleteProvisionedDashboard(ctx context.Context, dashboardID int64, orgID int64) error

DeleteProvisionedDashboard provides a mock function with given fields: ctx, dashboardID, orgID

func (*FakeDashboardProvisioning) GetProvisionedDashboardData

func (_m *FakeDashboardProvisioning) GetProvisionedDashboardData(ctx context.Context, name string) ([]*DashboardProvisioning, error)

GetProvisionedDashboardData provides a mock function with given fields: ctx, name

func (*FakeDashboardProvisioning) GetProvisionedDashboardDataByDashboardID

func (_m *FakeDashboardProvisioning) GetProvisionedDashboardDataByDashboardID(ctx context.Context, dashboardID int64) (*DashboardProvisioning, error)

GetProvisionedDashboardDataByDashboardID provides a mock function with given fields: ctx, dashboardID

func (*FakeDashboardProvisioning) GetProvisionedDashboardDataByDashboardUID

func (_m *FakeDashboardProvisioning) GetProvisionedDashboardDataByDashboardUID(ctx context.Context, orgID int64, dashboardUID string) (*DashboardProvisioning, error)

GetProvisionedDashboardDataByDashboardUID provides a mock function with given fields: ctx, orgID, dashboardUID

func (*FakeDashboardProvisioning) SaveFolderForProvisionedDashboards

func (_m *FakeDashboardProvisioning) SaveFolderForProvisionedDashboards(_a0 context.Context, _a1 *SaveDashboardDTO) (*Dashboard, error)

SaveFolderForProvisionedDashboards provides a mock function with given fields: _a0, _a1

func (*FakeDashboardProvisioning) SaveProvisionedDashboard

func (_m *FakeDashboardProvisioning) SaveProvisionedDashboard(ctx context.Context, dto *SaveDashboardDTO, provisioning *DashboardProvisioning) (*Dashboard, error)

SaveProvisionedDashboard provides a mock function with given fields: ctx, dto, provisioning

func (*FakeDashboardProvisioning) UnprovisionDashboard

func (_m *FakeDashboardProvisioning) UnprovisionDashboard(ctx context.Context, dashboardID int64) error

UnprovisionDashboard provides a mock function with given fields: ctx, dashboardID

type FakeDashboardService

type FakeDashboardService struct {
	mock.Mock
}

FakeDashboardService is an autogenerated mock type for the DashboardService type

func NewFakeDashboardService

func NewFakeDashboardService(t mockConstructorTestingTNewFakeDashboardService) *FakeDashboardService

NewFakeDashboardService creates a new instance of FakeDashboardService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*FakeDashboardService) BuildSaveDashboardCommand

func (_m *FakeDashboardService) BuildSaveDashboardCommand(ctx context.Context, dto *SaveDashboardDTO, shouldValidateAlerts bool, validateProvisionedDashboard bool) (*SaveDashboardCommand, error)

BuildSaveDashboardCommand provides a mock function with given fields: ctx, dto, shouldValidateAlerts, validateProvisionedDashboard

func (*FakeDashboardService) CountInFolder

func (_m *FakeDashboardService) CountInFolder(ctx context.Context, orgID int64, uid string, _a3 *user.SignedInUser) (int64, error)

CountInFolder provides a mock function with given fields: ctx, orgID, uid, _a3

func (*FakeDashboardService) DeleteACLByUser

func (_m *FakeDashboardService) DeleteACLByUser(ctx context.Context, userID int64) error

DeleteACLByUser provides a mock function with given fields: ctx, userID

func (*FakeDashboardService) DeleteDashboard

func (_m *FakeDashboardService) DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error

DeleteDashboard provides a mock function with given fields: ctx, dashboardId, orgId

func (*FakeDashboardService) FindDashboards

FindDashboards provides a mock function with given fields: ctx, query

func (*FakeDashboardService) GetDashboard

func (_m *FakeDashboardService) GetDashboard(ctx context.Context, query *GetDashboardQuery) (*Dashboard, error)

GetDashboard provides a mock function with given fields: ctx, query

func (*FakeDashboardService) GetDashboardACLInfoList

func (_m *FakeDashboardService) GetDashboardACLInfoList(ctx context.Context, query *GetDashboardACLInfoListQuery) ([]*DashboardACLInfoDTO, error)

GetDashboardACLInfoList provides a mock function with given fields: ctx, query

func (*FakeDashboardService) GetDashboardTags

func (_m *FakeDashboardService) GetDashboardTags(ctx context.Context, query *GetDashboardTagsQuery) ([]*DashboardTagCloudItem, error)

GetDashboardTags provides a mock function with given fields: ctx, query

func (*FakeDashboardService) GetDashboardUIDByID

func (_m *FakeDashboardService) GetDashboardUIDByID(ctx context.Context, query *GetDashboardRefByIDQuery) (*DashboardRef, error)

GetDashboardUIDByID provides a mock function with given fields: ctx, query

func (*FakeDashboardService) GetDashboards

func (_m *FakeDashboardService) GetDashboards(ctx context.Context, query *GetDashboardsQuery) ([]*Dashboard, error)

GetDashboards provides a mock function with given fields: ctx, query

func (*FakeDashboardService) ImportDashboard

func (_m *FakeDashboardService) ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*Dashboard, error)

ImportDashboard provides a mock function with given fields: ctx, dto

func (*FakeDashboardService) MakeUserAdmin

func (_m *FakeDashboardService) MakeUserAdmin(ctx context.Context, orgID int64, userID int64, dashboardID int64, setViewAndEditPermissions bool) error

MakeUserAdmin provides a mock function with given fields: ctx, orgID, userID, dashboardID, setViewAndEditPermissions

func (*FakeDashboardService) SaveDashboard

func (_m *FakeDashboardService) SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*Dashboard, error)

SaveDashboard provides a mock function with given fields: ctx, dto, allowUiUpdate

func (*FakeDashboardService) SearchDashboards

SearchDashboards provides a mock function with given fields: ctx, query

func (*FakeDashboardService) UpdateDashboardACL

func (_m *FakeDashboardService) UpdateDashboardACL(ctx context.Context, uid int64, items []*DashboardACL) error

UpdateDashboardACL provides a mock function with given fields: ctx, uid, items

type FakeDashboardStore

type FakeDashboardStore struct {
	mock.Mock
}

FakeDashboardStore is an autogenerated mock type for the Store type

func NewFakeDashboardStore

func NewFakeDashboardStore(t mockConstructorTestingTNewFakeDashboardStore) *FakeDashboardStore

NewFakeDashboardStore creates a new instance of FakeDashboardStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*FakeDashboardStore) Count

Count provides a mock function with given fields: _a0, _a1

func (*FakeDashboardStore) CountDashboardsInFolder

func (_m *FakeDashboardStore) CountDashboardsInFolder(ctx context.Context, request *CountDashboardsInFolderRequest) (int64, error)

CountDashboardsInFolder provides a mock function with given fields: ctx, request

func (*FakeDashboardStore) DeleteACLByUser

func (_m *FakeDashboardStore) DeleteACLByUser(_a0 context.Context, _a1 int64) error

DeleteACLByUser provides a mock function with given fields: _a0, _a1

func (*FakeDashboardStore) DeleteDashboard

func (_m *FakeDashboardStore) DeleteDashboard(ctx context.Context, cmd *DeleteDashboardCommand) error

DeleteDashboard provides a mock function with given fields: ctx, cmd

func (*FakeDashboardStore) DeleteDashboardsInFolder

func (_m *FakeDashboardStore) DeleteDashboardsInFolder(ctx context.Context, request *DeleteDashboardsInFolderRequest) error

DeleteDashboardsInFolder provides a mock function with given fields: ctx, request

func (*FakeDashboardStore) DeleteOrphanedProvisionedDashboards

func (_m *FakeDashboardStore) DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *DeleteOrphanedProvisionedDashboardsCommand) error

DeleteOrphanedProvisionedDashboards provides a mock function with given fields: ctx, cmd

func (*FakeDashboardStore) FindDashboards

FindDashboards provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboard

func (_m *FakeDashboardStore) GetDashboard(ctx context.Context, query *GetDashboardQuery) (*Dashboard, error)

GetDashboard provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboardACLInfoList

func (_m *FakeDashboardStore) GetDashboardACLInfoList(ctx context.Context, query *GetDashboardACLInfoListQuery) ([]*DashboardACLInfoDTO, error)

GetDashboardACLInfoList provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboardTags

func (_m *FakeDashboardStore) GetDashboardTags(ctx context.Context, query *GetDashboardTagsQuery) ([]*DashboardTagCloudItem, error)

GetDashboardTags provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboardUIDByID

func (_m *FakeDashboardStore) GetDashboardUIDByID(ctx context.Context, query *GetDashboardRefByIDQuery) (*DashboardRef, error)

GetDashboardUIDByID provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboards

func (_m *FakeDashboardStore) GetDashboards(ctx context.Context, query *GetDashboardsQuery) ([]*Dashboard, error)

GetDashboards provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetDashboardsByPluginID

func (_m *FakeDashboardStore) GetDashboardsByPluginID(ctx context.Context, query *GetDashboardsByPluginIDQuery) ([]*Dashboard, error)

GetDashboardsByPluginID provides a mock function with given fields: ctx, query

func (*FakeDashboardStore) GetProvisionedDashboardData

func (_m *FakeDashboardStore) GetProvisionedDashboardData(ctx context.Context, name string) ([]*DashboardProvisioning, error)

GetProvisionedDashboardData provides a mock function with given fields: ctx, name

func (*FakeDashboardStore) GetProvisionedDataByDashboardID

func (_m *FakeDashboardStore) GetProvisionedDataByDashboardID(ctx context.Context, dashboardID int64) (*DashboardProvisioning, error)

GetProvisionedDataByDashboardID provides a mock function with given fields: ctx, dashboardID

func (*FakeDashboardStore) GetProvisionedDataByDashboardUID

func (_m *FakeDashboardStore) GetProvisionedDataByDashboardUID(ctx context.Context, orgID int64, dashboardUID string) (*DashboardProvisioning, error)

GetProvisionedDataByDashboardUID provides a mock function with given fields: ctx, orgID, dashboardUID

func (*FakeDashboardStore) SaveAlerts

func (_m *FakeDashboardStore) SaveAlerts(ctx context.Context, dashID int64, alerts []*models.Alert) error

SaveAlerts provides a mock function with given fields: ctx, dashID, alerts

func (*FakeDashboardStore) SaveDashboard

func (_m *FakeDashboardStore) SaveDashboard(ctx context.Context, cmd SaveDashboardCommand) (*Dashboard, error)

SaveDashboard provides a mock function with given fields: ctx, cmd

func (*FakeDashboardStore) SaveProvisionedDashboard

func (_m *FakeDashboardStore) SaveProvisionedDashboard(ctx context.Context, cmd SaveDashboardCommand, provisioning *DashboardProvisioning) (*Dashboard, error)

SaveProvisionedDashboard provides a mock function with given fields: ctx, cmd, provisioning

func (*FakeDashboardStore) UnprovisionDashboard

func (_m *FakeDashboardStore) UnprovisionDashboard(ctx context.Context, id int64) error

UnprovisionDashboard provides a mock function with given fields: ctx, id

func (*FakeDashboardStore) UpdateDashboardACL

func (_m *FakeDashboardStore) UpdateDashboardACL(ctx context.Context, uid int64, items []*DashboardACL) error

UpdateDashboardACL provides a mock function with given fields: ctx, uid, items

func (*FakeDashboardStore) ValidateDashboardBeforeSave

func (_m *FakeDashboardStore) ValidateDashboardBeforeSave(ctx context.Context, dashboard *Dashboard, overwrite bool) (bool, error)

ValidateDashboardBeforeSave provides a mock function with given fields: ctx, dashboard, overwrite

type FindPersistedDashboardsQuery

type FindPersistedDashboardsQuery struct {
	Title         string
	OrgId         int64
	SignedInUser  *user.SignedInUser
	DashboardIds  []int64
	DashboardUIDs []string
	Type          string
	FolderIds     []int64
	FolderUIDs    []string
	Tags          []string
	Limit         int64
	Page          int64
	Permission    PermissionType
	Sort          model.SortOption

	Filters []interface{}
}

type GetDashboardACLInfoListQuery

type GetDashboardACLInfoListQuery struct {
	DashboardID int64
	OrgID       int64
}

QUERIES

type GetDashboardQuery

type GetDashboardQuery struct {
	ID       int64
	UID      string
	Title    *string
	FolderID *int64
	OrgID    int64
}

GetDashboardQuery is used to query for a single dashboard matching a unique constraint within the provided OrgID.

Available constraints:

  • ID uses Grafana's internal numeric database identifier to get a dashboard.
  • UID use the unique identifier to get a dashboard.
  • Title + FolderID uses the combination of the dashboard's human-readable title and its parent folder's ID (or zero, for top level items). Both are required if no other constraint is set.

Multiple constraints can be combined.

type GetDashboardRefByIDQuery

type GetDashboardRefByIDQuery struct {
	ID int64
}

type GetDashboardTagsQuery

type GetDashboardTagsQuery struct {
	OrgID int64
}

type GetDashboardsByPluginIDQuery

type GetDashboardsByPluginIDQuery struct {
	OrgID    int64
	PluginID string
}

type GetDashboardsQuery

type GetDashboardsQuery struct {
	DashboardIDs  []int64
	DashboardUIDs []string
	OrgID         int64
}

type PermissionType

type PermissionType int
const (
	PERMISSION_VIEW PermissionType = 1 << iota
	PERMISSION_EDIT
	PERMISSION_ADMIN
)

func (PermissionType) String

func (p PermissionType) String() string

type PluginService

type PluginService interface {
	GetDashboardsByPluginID(ctx context.Context, query *GetDashboardsByPluginIDQuery) ([]*Dashboard, error)
}

PluginService is a service for operating on plugin dashboards.

type SaveDashboardCommand

type SaveDashboardCommand struct {
	Dashboard    *simplejson.Json `json:"dashboard" binding:"Required"`
	UserID       int64            `json:"userId" xorm:"user_id"`
	Overwrite    bool             `json:"overwrite"`
	Message      string           `json:"message"`
	OrgID        int64            `json:"-" xorm:"org_id"`
	RestoredFrom int              `json:"-"`
	PluginID     string           `json:"-" xorm:"plugin_id"`
	FolderID     int64            `json:"folderId" xorm:"folder_id"`
	FolderUID    string           `json:"folderUid" xorm:"folder_uid"`
	IsFolder     bool             `json:"isFolder"`

	UpdatedAt time.Time
}

func (*SaveDashboardCommand) GetDashboardModel

func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard

GetDashboardModel turns the command into the saveable model

type SaveDashboardDTO

type SaveDashboardDTO struct {
	OrgID     int64
	UpdatedAt time.Time
	User      *user.SignedInUser
	Message   string
	Overwrite bool
	Dashboard *Dashboard
}

type Store

type Store interface {
	DeleteDashboard(ctx context.Context, cmd *DeleteDashboardCommand) error
	DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *DeleteOrphanedProvisionedDashboardsCommand) error
	FindDashboards(ctx context.Context, query *FindPersistedDashboardsQuery) ([]DashboardSearchProjection, error)
	GetDashboard(ctx context.Context, query *GetDashboardQuery) (*Dashboard, error)
	GetDashboardACLInfoList(ctx context.Context, query *GetDashboardACLInfoListQuery) ([]*DashboardACLInfoDTO, error)
	GetDashboardUIDByID(ctx context.Context, query *GetDashboardRefByIDQuery) (*DashboardRef, error)
	GetDashboards(ctx context.Context, query *GetDashboardsQuery) ([]*Dashboard, error)
	// GetDashboardsByPluginID retrieves dashboards identified by plugin.
	GetDashboardsByPluginID(ctx context.Context, query *GetDashboardsByPluginIDQuery) ([]*Dashboard, error)
	GetDashboardTags(ctx context.Context, query *GetDashboardTagsQuery) ([]*DashboardTagCloudItem, error)
	GetProvisionedDashboardData(ctx context.Context, name string) ([]*DashboardProvisioning, error)
	GetProvisionedDataByDashboardID(ctx context.Context, dashboardID int64) (*DashboardProvisioning, error)
	GetProvisionedDataByDashboardUID(ctx context.Context, orgID int64, dashboardUID string) (*DashboardProvisioning, error)
	// SaveAlerts saves dashboard alerts.
	SaveAlerts(ctx context.Context, dashID int64, alerts []*alertmodels.Alert) error
	SaveDashboard(ctx context.Context, cmd SaveDashboardCommand) (*Dashboard, error)
	SaveProvisionedDashboard(ctx context.Context, cmd SaveDashboardCommand, provisioning *DashboardProvisioning) (*Dashboard, error)
	UnprovisionDashboard(ctx context.Context, id int64) error
	UpdateDashboardACL(ctx context.Context, uid int64, items []*DashboardACL) error
	// ValidateDashboardBeforeSave validates a dashboard before save.
	ValidateDashboardBeforeSave(ctx context.Context, dashboard *Dashboard, overwrite bool) (bool, error)
	DeleteACLByUser(context.Context, int64) error

	Count(context.Context, *quota.ScopeParameters) (*quota.Map, error)
	// CountDashboardsInFolder returns the number of dashboards associated with
	// the given parent folder ID.
	CountDashboardsInFolder(ctx context.Context, request *CountDashboardsInFolderRequest) (int64, error)
	DeleteDashboardsInFolder(ctx context.Context, request *DeleteDashboardsInFolderRequest) error
}

Store is a dashboard store.

type TrimDashboardCommand

type TrimDashboardCommand struct {
	Dashboard *simplejson.Json `json:"dashboard" binding:"Required"`
	Meta      *simplejson.Json `json:"meta"`
}

type UpdatePluginDashboardError

type UpdatePluginDashboardError struct {
	PluginId string
}

func (UpdatePluginDashboardError) Error

type ValidateDashboardBeforeSaveResult

type ValidateDashboardBeforeSaveResult struct {
	IsParentFolderChanged bool
}

type ValidateDashboardCommand

type ValidateDashboardCommand struct {
	Dashboard string `json:"dashboard" binding:"Required"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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