api

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2022 License: BSD-3-Clause-LBNL Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagsFilter   = "TagsFilter"
	DashFilter   = "DashFilter"
	FolderFilter = "FolderFilter"
	Name         = "Name"
)

Currently supported filters

View Source
const (
	CloudType  = "cloud_type"
	BucketName = "bucket_name"
	Prefix     = "prefix"
)
View Source
const StorageContext = ContextStorage("storage")

Variables

View Source
var DefaultFolderName = "General"

Functions

func CreateDestinationPath

func CreateDestinationPath(v string)

CreateDestinationPath Handle osMkdir Errors

func GetSlug

func GetSlug(title string) string

Types

type ApiService

type ApiService interface {
	//Organizations
	ListOrganizations() []sdk.Org
	//Dashboard
	ListDashboards(filter Filter) []sdk.FoundBoard
	ImportDashboards(filter Filter) []string
	ExportDashboards(filter Filter)
	DeleteAllDashboards(filter Filter) []string
	//DataSources
	ListDataSources(filter Filter) []sdk.Datasource
	ImportDataSources(filter Filter) []string
	ExportDataSources(filter Filter) []string
	DeleteAllDataSources(filter Filter) []string
	//AlertNotifications
	ListAlertNotifications() []sdk.AlertNotification
	ImportAlertNotifications() []string
	ExportAlertNotifications() []string
	DeleteAllAlertNotifications() []string
	//Login
	Login() *sdk.Client
	AdminLogin() *sdk.Client
	//User
	ListUsers() []sdk.User
	ImportUsers() []string
	ExportUsers() []sdk.User
	PromoteUser(userLogin string) (*sdk.StatusMessage, error)
	DeleteAllUsers() []string
	//MetaData
	GetServerInfo() map[string]interface{}
	//Folder
	ListFolder(filter Filter) []sdk.Folder
	ImportFolder(filter Filter) []string
	ExportFolder(filter Filter) []string
	DeleteAllFolder(filter Filter) []string
}

func NewApiService

func NewApiService(override ...string) ApiService

type BaseFilter

type BaseFilter struct {
	Filters map[string]string
}

func (BaseFilter) AddFilter

func (s BaseFilter) AddFilter(key, value string)

AddFilter adds a filter and the corresponding value

func (BaseFilter) GetFilter

func (s BaseFilter) GetFilter(key string) string

GetFilter returns the value of the filter

func (BaseFilter) GetTypes

func (s BaseFilter) GetTypes() []string

GetTypes returns all the current keys for the configured Filter

func (*BaseFilter) Init

func (s *BaseFilter) Init()

type CloudStorage

type CloudStorage struct {
	Location    stow.Location
	BucketName  string
	BucketRef   stow.Container
	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

func (*CloudStorage) ReadFile

func (s *CloudStorage) ReadFile(filename string) ([]byte, error)

ReadFile read file from Cloud Provider and return byte array

func (*CloudStorage) WriteFile

func (s *CloudStorage) WriteFile(filename string, data []byte, mode fs.FileMode) error

WriteFile persists data to Cloud Provider Storage returning error if operation failed

type ContextStorage

type ContextStorage string

type DashNGoImpl

type DashNGoImpl struct {
	// contains filtered or unexported fields
}

func NewDashNGoImpl

func NewDashNGoImpl() *DashNGoImpl

func (*DashNGoImpl) AdminLogin

func (s *DashNGoImpl) AdminLogin() *sdk.Client

func (*DashNGoImpl) DeleteAllAlertNotifications

func (s *DashNGoImpl) DeleteAllAlertNotifications() []string

Removes all current alert notification channels

func (*DashNGoImpl) DeleteAllDashboards

func (s *DashNGoImpl) DeleteAllDashboards(filter 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 Filter) []string

Removes all current datasources

func (*DashNGoImpl) DeleteAllFolder

func (s *DashNGoImpl) DeleteAllFolder(filter Filter) []string

func (*DashNGoImpl) DeleteAllUsers

func (s *DashNGoImpl) DeleteAllUsers() []string

DeleteAllUsers

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(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 Filter) []string

ExportDataSources: exports all datasources to grafana using the credentials configured in config file.

func (*DashNGoImpl) ExportFolder

func (s *DashNGoImpl) ExportFolder(filter Filter) []string

func (*DashNGoImpl) ExportUsers

func (s *DashNGoImpl) ExportUsers() []sdk.User

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 Filter) []string

ImportDashboards saves all dashboards matching query to configured location

func (*DashNGoImpl) ImportDataSources

func (s *DashNGoImpl) ImportDataSources(filter 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 Filter) []string

func (*DashNGoImpl) ImportUsers

func (s *DashNGoImpl) ImportUsers() []string

func (*DashNGoImpl) ListAlertNotifications

func (s *DashNGoImpl) ListAlertNotifications() []sdk.AlertNotification

func (*DashNGoImpl) ListDashboards

func (s *DashNGoImpl) ListDashboards(filters Filter) []sdk.FoundBoard

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 Filter) []sdk.Datasource

ListDataSources: list all the currently configured datasources

func (*DashNGoImpl) ListFolder

func (s *DashNGoImpl) ListFolder(filter Filter) []sdk.Folder

func (*DashNGoImpl) ListOrganizations

func (s *DashNGoImpl) ListOrganizations() []sdk.Org

ListOrganizations: List all dashboards

func (*DashNGoImpl) ListUsers

func (s *DashNGoImpl) ListUsers() []sdk.User

ListUsers list all grafana users

func (*DashNGoImpl) Login

func (s *DashNGoImpl) Login() *sdk.Client

Login: Logs into grafana returning a client instance using Token or Basic Auth

func (*DashNGoImpl) PromoteUser

func (s *DashNGoImpl) PromoteUser(userLogin string) (*sdk.StatusMessage, error)

PromoteUser promote the user to have Admin Access

func (*DashNGoImpl) SetStorage

func (s *DashNGoImpl) SetStorage(v Storage)

Testing Only

type DashboardFilter

type DashboardFilter struct {
	BaseFilter
	// contains filtered or unexported fields
}

func NewDashboardFilter

func NewDashboardFilter() *DashboardFilter

NewDashboardFilter creates a new dashboard filter

func (*DashboardFilter) GetFolders

func (s *DashboardFilter) GetFolders() []string

GetFolders splits the comma delimited folder list and returns a slice

func (*DashboardFilter) GetTags

func (s *DashboardFilter) GetTags() []string

GetTags returns a list of all tags to filter on

func (DashboardFilter) Validate

func (s DashboardFilter) Validate(items map[string]string) bool

type DatasourceFilter

type DatasourceFilter struct {
	BaseFilter
}

func (DatasourceFilter) GetFolders

func (s DatasourceFilter) GetFolders() []string

GetFolders return empty list since Folders NA for datasources

func (DatasourceFilter) GetTags

func (s DatasourceFilter) GetTags() []string

GetTags return empty list since Tags NA for datasources

func (DatasourceFilter) Validate

func (s DatasourceFilter) Validate(items map[string]string) bool

Validate returns true if mapped values are valid

type Filter

type Filter interface {
	GetTypes() []string                    //Return list of active Filter Types
	GetFilter(key string) string           //Get the Filter value
	AddFilter(key, value string)           //Add a filter query
	Validate(items map[string]string) bool //Validate if Entry is valid
	GetFolders() []string                  //List of supported folders if Any
	GetTags() []string                     //List of tags
}

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

func (*LocalStorage) ReadFile

func (s *LocalStorage) ReadFile(filename string) ([]byte, error)

ReadFile returns a byte array of file content

func (*LocalStorage) WriteFile

func (s *LocalStorage) WriteFile(filename string, data []byte, mode fs.FileMode) error

WriteFile writes file to disk and returns an error if operation failed

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 NewCloudStorage

func NewCloudStorage(c context.Context) (Storage, error)

func NewLocalStorage

func NewLocalStorage(ctx context.Context) Storage

Jump to

Keyboard shortcuts

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