2022-02-16 07:15:44 -06:00
|
|
|
package dashboards
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2022-06-13 18:23:56 -05:00
|
|
|
"github.com/grafana/grafana/pkg/api/dtos"
|
2022-02-16 07:15:44 -06:00
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
|
|
)
|
|
|
|
|
2022-05-23 10:14:27 -05:00
|
|
|
//go:generate mockery --name DashboardService --structname FakeDashboardService --inpackage --filename dashboard_service_mock.go
|
2022-02-16 07:15:44 -06:00
|
|
|
// DashboardService is a service for operating on dashboards.
|
|
|
|
type DashboardService interface {
|
2022-06-13 18:23:56 -05:00
|
|
|
BuildPublicDashboardMetricRequest(ctx context.Context, publicDashboardUid string, panelId int64) (dtos.MetricRequest, error)
|
2022-05-19 09:13:02 -05:00
|
|
|
BuildSaveDashboardCommand(ctx context.Context, dto *SaveDashboardDTO, shouldValidateAlerts bool, validateProvisionedDashboard bool) (*models.SaveDashboardCommand, error)
|
|
|
|
DeleteDashboard(ctx context.Context, dashboardId int64, orgId int64) error
|
2022-05-23 10:14:27 -05:00
|
|
|
FindDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) ([]DashboardSearchProjection, error)
|
2022-05-19 09:13:02 -05:00
|
|
|
GetDashboard(ctx context.Context, query *models.GetDashboardQuery) error
|
2022-06-01 13:16:26 -05:00
|
|
|
GetDashboardAclInfoList(ctx context.Context, query *models.GetDashboardAclInfoListQuery) error
|
2022-05-19 09:59:12 -05:00
|
|
|
GetDashboards(ctx context.Context, query *models.GetDashboardsQuery) error
|
2022-06-02 09:00:47 -05:00
|
|
|
GetDashboardTags(ctx context.Context, query *models.GetDashboardTagsQuery) error
|
2022-05-19 09:13:02 -05:00
|
|
|
GetDashboardUIDById(ctx context.Context, query *models.GetDashboardRefByIdQuery) error
|
2022-06-02 21:27:23 -05:00
|
|
|
GetPublicDashboard(ctx context.Context, publicDashboardUid string) (*models.Dashboard, error)
|
2022-05-17 17:11:55 -05:00
|
|
|
GetPublicDashboardConfig(ctx context.Context, orgId int64, dashboardUid string) (*models.PublicDashboardConfig, error)
|
2022-06-01 13:16:26 -05:00
|
|
|
HasAdminPermissionInFolders(ctx context.Context, query *models.HasAdminPermissionInFoldersQuery) error
|
|
|
|
HasEditPermissionInFolders(ctx context.Context, query *models.HasEditPermissionInFoldersQuery) error
|
2022-02-16 07:15:44 -06:00
|
|
|
ImportDashboard(ctx context.Context, dto *SaveDashboardDTO) (*models.Dashboard, error)
|
|
|
|
MakeUserAdmin(ctx context.Context, orgID int64, userID, dashboardID int64, setViewAndEditPermissions bool) error
|
2022-05-19 09:13:02 -05:00
|
|
|
SaveDashboard(ctx context.Context, dto *SaveDashboardDTO, allowUiUpdate bool) (*models.Dashboard, error)
|
|
|
|
SavePublicDashboardConfig(ctx context.Context, dto *SavePublicDashboardConfigDTO) (*models.PublicDashboardConfig, error)
|
2022-05-23 10:14:27 -05:00
|
|
|
SearchDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) error
|
2022-02-16 07:15:44 -06:00
|
|
|
UpdateDashboardACL(ctx context.Context, uid int64, items []*models.DashboardAcl) error
|
|
|
|
}
|
|
|
|
|
2022-03-10 11:38:04 -06:00
|
|
|
// PluginService is a service for operating on plugin dashboards.
|
|
|
|
type PluginService interface {
|
|
|
|
GetDashboardsByPluginID(ctx context.Context, query *models.GetDashboardsByPluginIdQuery) error
|
|
|
|
}
|
|
|
|
|
2022-02-16 07:15:44 -06:00
|
|
|
//go:generate mockery --name DashboardProvisioningService --structname FakeDashboardProvisioning --inpackage --filename dashboard_provisioning_mock.go
|
|
|
|
// DashboardProvisioningService is a service for operating on provisioned dashboards.
|
|
|
|
type DashboardProvisioningService interface {
|
2022-05-19 09:13:02 -05:00
|
|
|
DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *models.DeleteOrphanedProvisionedDashboardsCommand) error
|
|
|
|
DeleteProvisionedDashboard(ctx context.Context, dashboardID int64, orgID int64) error
|
2022-02-16 07:15:44 -06:00
|
|
|
GetProvisionedDashboardData(name string) ([]*models.DashboardProvisioning, error)
|
|
|
|
GetProvisionedDashboardDataByDashboardID(dashboardID int64) (*models.DashboardProvisioning, error)
|
2022-05-19 09:13:02 -05:00
|
|
|
GetProvisionedDashboardDataByDashboardUID(orgID int64, dashboardUID string) (*models.DashboardProvisioning, error)
|
|
|
|
SaveFolderForProvisionedDashboards(context.Context, *SaveDashboardDTO) (*models.Dashboard, error)
|
|
|
|
SaveProvisionedDashboard(ctx context.Context, dto *SaveDashboardDTO, provisioning *models.DashboardProvisioning) (*models.Dashboard, error)
|
2022-02-16 07:15:44 -06:00
|
|
|
UnprovisionDashboard(ctx context.Context, dashboardID int64) error
|
|
|
|
}
|
|
|
|
|
2022-05-19 09:59:12 -05:00
|
|
|
//go:generate mockery --name Store --structname FakeDashboardStore --inpackage --filename store_mock.go
|
2022-02-16 07:15:44 -06:00
|
|
|
// Store is a dashboard store.
|
|
|
|
type Store interface {
|
2022-05-19 09:13:02 -05:00
|
|
|
DeleteDashboard(ctx context.Context, cmd *models.DeleteDashboardCommand) error
|
|
|
|
DeleteOrphanedProvisionedDashboards(ctx context.Context, cmd *models.DeleteOrphanedProvisionedDashboardsCommand) error
|
2022-05-23 10:14:27 -05:00
|
|
|
FindDashboards(ctx context.Context, query *models.FindPersistedDashboardsQuery) ([]DashboardSearchProjection, error)
|
2022-06-07 04:02:20 -05:00
|
|
|
GetDashboard(ctx context.Context, query *models.GetDashboardQuery) (*models.Dashboard, error)
|
2022-06-01 13:16:26 -05:00
|
|
|
GetDashboardAclInfoList(ctx context.Context, query *models.GetDashboardAclInfoListQuery) error
|
2022-05-19 09:13:02 -05:00
|
|
|
GetDashboardUIDById(ctx context.Context, query *models.GetDashboardRefByIdQuery) error
|
2022-05-19 09:59:12 -05:00
|
|
|
GetDashboards(ctx context.Context, query *models.GetDashboardsQuery) error
|
2022-05-19 09:13:02 -05:00
|
|
|
// GetDashboardsByPluginID retrieves dashboards identified by plugin.
|
|
|
|
GetDashboardsByPluginID(ctx context.Context, query *models.GetDashboardsByPluginIdQuery) error
|
2022-06-02 09:00:47 -05:00
|
|
|
GetDashboardTags(ctx context.Context, query *models.GetDashboardTagsQuery) error
|
2022-05-19 09:13:02 -05:00
|
|
|
GetProvisionedDashboardData(name string) ([]*models.DashboardProvisioning, error)
|
2022-02-16 07:15:44 -06:00
|
|
|
GetProvisionedDataByDashboardID(dashboardID int64) (*models.DashboardProvisioning, error)
|
|
|
|
GetProvisionedDataByDashboardUID(orgID int64, dashboardUID string) (*models.DashboardProvisioning, error)
|
2022-05-17 17:11:55 -05:00
|
|
|
GetPublicDashboardConfig(orgId int64, dashboardUid string) (*models.PublicDashboardConfig, error)
|
2022-06-02 21:27:23 -05:00
|
|
|
GetPublicDashboard(uid string) (*models.PublicDashboard, *models.Dashboard, error)
|
2022-06-01 13:16:26 -05:00
|
|
|
HasAdminPermissionInFolders(ctx context.Context, query *models.HasAdminPermissionInFoldersQuery) error
|
|
|
|
HasEditPermissionInFolders(ctx context.Context, query *models.HasEditPermissionInFoldersQuery) error
|
2022-02-16 07:15:44 -06:00
|
|
|
// SaveAlerts saves dashboard alerts.
|
|
|
|
SaveAlerts(ctx context.Context, dashID int64, alerts []*models.Alert) error
|
2022-05-19 09:13:02 -05:00
|
|
|
SaveDashboard(cmd models.SaveDashboardCommand) (*models.Dashboard, error)
|
|
|
|
SaveProvisionedDashboard(cmd models.SaveDashboardCommand, provisioning *models.DashboardProvisioning) (*models.Dashboard, error)
|
|
|
|
SavePublicDashboardConfig(cmd models.SavePublicDashboardConfigCommand) (*models.PublicDashboardConfig, error)
|
2022-02-16 07:15:44 -06:00
|
|
|
UnprovisionDashboard(ctx context.Context, id int64) error
|
2022-05-19 09:13:02 -05:00
|
|
|
UpdateDashboardACL(ctx context.Context, uid int64, items []*models.DashboardAcl) error
|
|
|
|
// ValidateDashboardBeforeSave validates a dashboard before save.
|
|
|
|
ValidateDashboardBeforeSave(dashboard *models.Dashboard, overwrite bool) (bool, error)
|
|
|
|
|
2022-03-14 10:21:42 -05:00
|
|
|
FolderStore
|
|
|
|
}
|
|
|
|
|
|
|
|
//go:generate mockery --name FolderStore --structname FakeFolderStore --inpackage --filename folder_store_mock.go
|
|
|
|
// FolderStore is a folder store.
|
|
|
|
type FolderStore interface {
|
|
|
|
// GetFolderByTitle retrieves a folder by its title
|
|
|
|
GetFolderByTitle(ctx context.Context, orgID int64, title string) (*models.Folder, error)
|
|
|
|
// GetFolderByUID retrieves a folder by its UID
|
|
|
|
GetFolderByUID(ctx context.Context, orgID int64, uid string) (*models.Folder, error)
|
|
|
|
// GetFolderByID retrieves a folder by its ID
|
|
|
|
GetFolderByID(ctx context.Context, orgID int64, id int64) (*models.Folder, error)
|
2022-02-16 07:15:44 -06:00
|
|
|
}
|