grafana

package
v0.11.2-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DashboardRoleViewer = "view"
	DashboardRoleEditor = "edit"
	DashboardRoleAdmin  = "admin"

	AccountTypeUser = "user"
)
View Source
const (
	ResourceTypeFolder    = "folder"
	ResourceTypeDashboard = "dashboard"
)

Variables

View Source
var (
	ErrInvalidRole                   = errors.New("invalid role")
	ErrInvalidPermissionType         = errors.New("invalid permission type")
	ErrUserNotFound                  = errors.New("cannot find user with the given email")
	ErrPermissionNotFound            = errors.New("permission not found")
	ErrInvalidResourceType           = errors.New("invalid resource type")
	ErrInvalidCredentials            = errors.New("invalid credentials type")
	ErrInvalidPermissionConfig       = errors.New("invalid permission config type")
	ErrUnableToEncryptNilCredentials = errors.New("unable to encrypt nil credentials")
	ErrUnableToDecryptNilCredentials = errors.New("unable to decrypt nil credentials")
)

Functions

func NewClient

func NewClient(config *ClientConfig) (*client, error)

func NewProvider

func NewProvider(typeName string, crypto domain.Crypto) *provider

Types

type ClientConfig

type ClientConfig struct {
	Host       string `validate:"required,url" mapstructure:"host"`
	Username   string `validate:"required" mapstructure:"username"`
	Password   string `validate:"required" mapstructure:"password"`
	Org        string `validate:"required" mapstructure:"org"`
	HTTPClient HTTPClient
}

type Config

type Config struct {
	ProviderConfig *domain.ProviderConfig
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(pc *domain.ProviderConfig, crypto domain.Crypto) *Config

func (*Config) EncryptCredentials

func (c *Config) EncryptCredentials() error

func (*Config) ParseAndValidate

func (c *Config) ParseAndValidate() error

type Credentials

type Credentials struct {
	Host     string `json:"host" mapstructure:"host" validate:"required,url"`
	Username string `json:"username" mapstructure:"username" validate:"required"`
	Password string `json:"password" mapstructure:"password" validate:"required"`
}

func (*Credentials) Decrypt

func (c *Credentials) Decrypt(decryptor domain.Decryptor) error

func (*Credentials) Encrypt

func (c *Credentials) Encrypt(encryptor domain.Encryptor) error

type Dashboard

type Dashboard struct {
	ID          int    `json:"id"`
	UID         string `json:"uid"`
	Title       string `json:"title"`
	Slug        string `json:"slug"`
	FolderID    int    `json:"folderId"`
	FolderUID   string `json:"folderUid"`
	FolderTitle string `json:"folderTitle"`
}

func (*Dashboard) FromDomain

func (d *Dashboard) FromDomain(r *domain.Resource) error

func (*Dashboard) ToDomain

func (d *Dashboard) ToDomain() *domain.Resource

type Folder

type Folder struct {
	ID    int    `json:"id"`
	UID   string `json:"uid"`
	Title string `json:"title"`
}

type GrafanaClient

type GrafanaClient interface {
	GetDashboards(folderId int) ([]*Dashboard, error)
	GetFolders() ([]*Folder, error)
	GrantDashboardAccess(resource *Dashboard, user, role string) error
	RevokeDashboardAccess(resource *Dashboard, user, role string) error
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Permission

type Permission string

type PermissionRequest

type PermissionRequest struct {
	UserID     int    `json:"userId,omitempty"`
	TeamID     int    `json:"teamId,omitempty"`
	Permission int    `json:"permission"`
	Role       string `json:"role,omitempty"`
	Inherited  bool   `json:"inherited,omitempty"`
}

type UpdatePermissionRequest

type UpdatePermissionRequest struct {
	Items []*PermissionRequest `json:"items"`
}

Jump to

Keyboard shortcuts

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