Documentation
¶
Index ¶
- Constants
- Variables
- func CreateDestinationPath(v string)
- func DefaultUserPassword(username string) string
- func GetSlug(title string) string
- func NewDashboardFilter(entries ...string) filters.Filter
- func NewDataSourceFilter(name string) filters.Filter
- func NewFolderFilter() filters.Filter
- type AlertNotificationsApi
- type ApiService
- type AuthenticationApi
- type CloudStorage
- type ContextStorage
- type DashNGoImpl
- func (s *DashNGoImpl) ClearAPIKeys() error
- func (s *DashNGoImpl) CreateAdminAPIKey(name string) *models.NewAPIKeyResult
- func (s *DashNGoImpl) DeleteAPIKey(id int64) error
- func (s *DashNGoImpl) DeleteAllAlertNotifications() []string
- func (s *DashNGoImpl) DeleteAllDashboards(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) DeleteAllUsers() []string
- func (s *DashNGoImpl) ExportAlertNotifications() []string
- func (s *DashNGoImpl) ExportDashboards(filterReq filters.Filter)
- func (s *DashNGoImpl) ExportDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) ExportUsers() []models.UserProfileDTO
- func (s *DashNGoImpl) GetServerInfo() map[string]interface{}
- func (s *DashNGoImpl) ImportAlertNotifications() []string
- func (s *DashNGoImpl) ImportDashboards(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportDataSources(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportFolder(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportLibraryElements(filter filters.Filter) []string
- func (s *DashNGoImpl) ImportUsers() []string
- func (s *DashNGoImpl) ListAlertNotifications() []*models.AlertNotification
- func (s *DashNGoImpl) ListDashboards(filterReq filters.Filter) []*models.Hit
- func (s *DashNGoImpl) ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
- func (s *DashNGoImpl) ListFolder(filter filters.Filter) []*models.Hit
- func (s *DashNGoImpl) ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
- func (s *DashNGoImpl) ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
- func (s *DashNGoImpl) ListOrganizations() []*models.OrgDTO
- func (s *DashNGoImpl) ListUsers() []*models.UserSearchHitDTO
- func (s *DashNGoImpl) Login()
- func (s *DashNGoImpl) PromoteUser(userLogin string) (string, error)
- func (s *DashNGoImpl) SetStorage(v Storage)
- type DashboardsApi
- type DataSourcesApi
- type FoldersApi
- type LibraryElementsApi
- type LocalStorage
- type OrganizationsApi
- type Storage
- type UsersApi
Constants ¶
const ( CloudType = "cloud_type" BucketName = "bucket_name" Prefix = "prefix" )
const StorageContext = ContextStorage("storage")
Variables ¶
var ( DefaultFolderName = "General" DefaultFolderId = int64(0) )
Functions ¶
func CreateDestinationPath ¶
func CreateDestinationPath(v string)
CreateDestinationPath Handle osMkdir Errors
func DefaultUserPassword ¶ added in v0.4.0
func NewDashboardFilter ¶
func NewDataSourceFilter ¶ added in v0.4.0
func NewFolderFilter ¶ added in v0.4.0
Types ¶
type AlertNotificationsApi ¶ added in v0.4.0
type AlertNotificationsApi interface {
ListAlertNotifications() []*models.AlertNotification
ImportAlertNotifications() []string
ExportAlertNotifications() []string
DeleteAllAlertNotifications() []string
}
AlertNotificationsApi Contract definition Deprecated: Marked as Deprecated as of Grafana 9.0, Moving to ContactPoints is recommended
type ApiService ¶
type ApiService interface {
OrganizationsApi
DashboardsApi
DataSourcesApi
AlertNotificationsApi
UsersApi
FoldersApi
LibraryElementsApi
//MetaData
GetServerInfo() map[string]interface{}
}
func NewApiService ¶
func NewApiService(override ...string) ApiService
type AuthenticationApi ¶ added in v0.4.0
type AuthenticationApi interface {
Login()
AdminLogin()
}
AuthenticationApi Contract definition
type CloudStorage ¶
type CloudStorage struct {
BucketRef *blob.Bucket
BucketName string
Prefix string
StorageName string
}
func (*CloudStorage) FindAllFiles ¶
func (s *CloudStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)
func (*CloudStorage) Name ¶
func (s *CloudStorage) Name() string
type ContextStorage ¶
type ContextStorage string
type DashNGoImpl ¶
type DashNGoImpl struct {
// contains filtered or unexported fields
}
func NewDashNGoImpl ¶
func NewDashNGoImpl() *DashNGoImpl
func (*DashNGoImpl) ClearAPIKeys ¶ added in v0.4.1
func (s *DashNGoImpl) ClearAPIKeys() error
func (*DashNGoImpl) CreateAdminAPIKey ¶ added in v0.4.1
func (s *DashNGoImpl) CreateAdminAPIKey(name string) *models.NewAPIKeyResult
func (*DashNGoImpl) DeleteAPIKey ¶ added in v0.4.1
func (s *DashNGoImpl) DeleteAPIKey(id int64) error
func (*DashNGoImpl) DeleteAllAlertNotifications ¶
func (s *DashNGoImpl) DeleteAllAlertNotifications() []string
Removes all current alert notification channels
func (*DashNGoImpl) DeleteAllDashboards ¶
func (s *DashNGoImpl) DeleteAllDashboards(filter filters.Filter) []string
DeleteAllDashboards clears all current dashboards being monitored. Any folder not white listed will not be affected
func (*DashNGoImpl) DeleteAllDataSources ¶
func (s *DashNGoImpl) DeleteAllDataSources(filter filters.Filter) []string
Removes all current datasources
func (*DashNGoImpl) DeleteAllFolder ¶
func (s *DashNGoImpl) DeleteAllFolder(filter filters.Filter) []string
func (*DashNGoImpl) DeleteAllLibraryElements ¶ added in v0.4.0
func (s *DashNGoImpl) DeleteAllLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) ExportAlertNotifications ¶
func (s *DashNGoImpl) ExportAlertNotifications() []string
ExportAlertNotifications: exports all alert notification channels to grafana. NOTE: credentials will be missing and need to be set manually after export TODO implement configuring sensitive fields for different kinds of alert notification channels
func (*DashNGoImpl) ExportDashboards ¶
func (s *DashNGoImpl) ExportDashboards(filterReq filters.Filter)
ExportDashboards finds all the dashboards in the configured location and exports them to grafana. if the folder doesn't exist, it'll be created.
func (*DashNGoImpl) ExportDataSources ¶
func (s *DashNGoImpl) ExportDataSources(filter filters.Filter) []string
ExportDataSources: exports all datasources to grafana using the credentials configured in config file.
func (*DashNGoImpl) ExportFolder ¶
func (s *DashNGoImpl) ExportFolder(filter filters.Filter) []string
func (*DashNGoImpl) ExportLibraryElements ¶ added in v0.4.0
func (s *DashNGoImpl) ExportLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) ExportUsers ¶
func (s *DashNGoImpl) ExportUsers() []models.UserProfileDTO
func (*DashNGoImpl) GetServerInfo ¶
func (s *DashNGoImpl) GetServerInfo() map[string]interface{}
GetServerInfo returns basic Grafana Server info
func (*DashNGoImpl) ImportAlertNotifications ¶
func (s *DashNGoImpl) ImportAlertNotifications() []string
ImportAlertNotifications: will read in all the configured alert notification channels.
func (*DashNGoImpl) ImportDashboards ¶
func (s *DashNGoImpl) ImportDashboards(filter filters.Filter) []string
ImportDashboards saves all dashboards matching query to configured location
func (*DashNGoImpl) ImportDataSources ¶
func (s *DashNGoImpl) ImportDataSources(filter filters.Filter) []string
ImportDataSources: will read in all the configured datasources. NOTE: credentials cannot be retrieved and need to be set via configuration
func (*DashNGoImpl) ImportFolder ¶
func (s *DashNGoImpl) ImportFolder(filter filters.Filter) []string
func (*DashNGoImpl) ImportLibraryElements ¶ added in v0.4.0
func (s *DashNGoImpl) ImportLibraryElements(filter filters.Filter) []string
func (*DashNGoImpl) ImportUsers ¶
func (s *DashNGoImpl) ImportUsers() []string
func (*DashNGoImpl) ListAlertNotifications ¶
func (s *DashNGoImpl) ListAlertNotifications() []*models.AlertNotification
func (*DashNGoImpl) ListDashboards ¶
func (s *DashNGoImpl) ListDashboards(filterReq filters.Filter) []*models.Hit
ListDashboards List all dashboards optionally filtered by folder name. If folderFilters is blank, defaults to the configured Monitored folders
func (*DashNGoImpl) ListDataSources ¶
func (s *DashNGoImpl) ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
func (*DashNGoImpl) ListFolder ¶
func (s *DashNGoImpl) ListFolder(filter filters.Filter) []*models.Hit
func (*DashNGoImpl) ListLibraryElements ¶ added in v0.4.0
func (s *DashNGoImpl) ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
func (*DashNGoImpl) ListLibraryElementsConnections ¶ added in v0.4.1
func (s *DashNGoImpl) ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
func (*DashNGoImpl) ListOrganizations ¶
func (s *DashNGoImpl) ListOrganizations() []*models.OrgDTO
ListOrganizations: List all dashboards
func (*DashNGoImpl) ListUsers ¶
func (s *DashNGoImpl) ListUsers() []*models.UserSearchHitDTO
ListUsers list all grafana users
func (*DashNGoImpl) Login ¶
func (s *DashNGoImpl) Login()
Login Logs into grafana returning a legacyClient instance using Token or Basic Auth
func (*DashNGoImpl) PromoteUser ¶
func (s *DashNGoImpl) PromoteUser(userLogin string) (string, error)
PromoteUser promote the user to have Admin Access
type DashboardsApi ¶ added in v0.4.0
type DashboardsApi interface {
ListDashboards(filter filters.Filter) []*models.Hit
ImportDashboards(filter filters.Filter) []string
ExportDashboards(filter filters.Filter)
DeleteAllDashboards(filter filters.Filter) []string
// contains filtered or unexported methods
}
DashboardsApi Contract definition
type DataSourcesApi ¶ added in v0.4.0
type DataSourcesApi interface {
ListDataSources(filter filters.Filter) []models.DataSourceListItemDTO
ImportDataSources(filter filters.Filter) []string
ExportDataSources(filter filters.Filter) []string
DeleteAllDataSources(filter filters.Filter) []string
}
DataSourcesApi Contract definition
type FoldersApi ¶ added in v0.4.0
type FoldersApi interface {
ListFolder(filter filters.Filter) []*models.Hit
ImportFolder(filter filters.Filter) []string
ExportFolder(filter filters.Filter) []string
DeleteAllFolder(filter filters.Filter) []string
}
FoldersApi Contract definition
type LibraryElementsApi ¶ added in v0.4.0
type LibraryElementsApi interface {
ListLibraryElements(filter filters.Filter) []*models.LibraryElementDTO
ListLibraryElementsConnections(filter filters.Filter, connectionID string) []*models.DashboardFullWithMeta
ImportLibraryElements(filter filters.Filter) []string
ExportLibraryElements(filter filters.Filter) []string
DeleteAllLibraryElements(filter filters.Filter) []string
}
type LocalStorage ¶
type LocalStorage struct {
}
LocalStorage default storage engine
func (*LocalStorage) FindAllFiles ¶
func (s *LocalStorage) FindAllFiles(folder string, fullPath bool) ([]string, error)
func (LocalStorage) Name ¶
func (LocalStorage) Name() string
type OrganizationsApi ¶ added in v0.4.0
OrganizationsApi Contract definition
type Storage ¶
type Storage interface {
WriteFile(filename string, data []byte, mode fs.FileMode) error // WriteFile returns error or writes byte array to destination
ReadFile(filename string) ([]byte, error) // ReadFile returns byte array or error with data from file
FindAllFiles(folder string, fullPath bool) ([]string, error) // FindAllFiles recursively list all files for a given path
Name() string // Name of storage engine
}
TODO: pull all the cloud based interaction into a Plugin System
func NewLocalStorage ¶
type UsersApi ¶ added in v0.4.0
type UsersApi interface {
//User
ListUsers() []*models.UserSearchHitDTO
ImportUsers() []string
ExportUsers() []models.UserProfileDTO
PromoteUser(userLogin string) (string, error)
DeleteAllUsers() []string
//TODO: clean up and expose API Keys management via CLI
CreateAdminAPIKey(name string) *models.NewAPIKeyResult
DeleteAPIKey(id int64) error
ClearAPIKeys() error
}
UsersApi Contract definition