instance

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Name            string `json:"name"`
	DisplayName     string `json:"displayName"`
	Description     string `json:"description"`
	Home            bool   `json:"home"`
	InternalAddress string `json:"internalAddress"`
	PublicAddress   string `json:"publicAddress"`
	Username        string `json:"username"`
	Password        string `json:"password"`
	Token           string `json:"token"`
}

Config is the structure of the configuration for a single Grafana instance.

type Dashboard

type Dashboard struct {
	DashboardData
	DashboardMetadata
	Type string `json:"type,omitempty"`
}

Dashboard is the structure of a single Grafana dashboard. It contains the dashboard data and metadata. If this is used via the search API it also contains a type field, because the API also returns folders.

type DashboardData

type DashboardData struct {
	ID    int      `json:"id"`
	UID   string   `json:"uid"`
	Title string   `json:"title"`
	Tags  []string `json:"tags"`
}

DashboardData is the structure for the dashbord data returned by the Grafana API.

type DashboardMetadata

type DashboardMetadata struct {
	URL         string `json:"url"`
	FolderID    int    `json:"folderId"`
	FolderUID   string `json:"folderUid"`
	FolderTitle string `json:"folderTitle,omitempty"`
	FolderURL   string `json:"folderUrl,omitempty"`
}

DashboardMetadata contains the metadata of a dashboard returned by the Grafana API.

type Instance

type Instance interface {
	GetName() string
	GetDashboards(ctx context.Context, query string) ([]Dashboard, error)
	GetDashboard(ctx context.Context, uid string) (*Dashboard, error)
	// contains filtered or unexported methods
}

Instance is the interface which must be implemented by each configured Grafana instance.

func New

func New(config Config) Instance

New returns a new Grafana instance for the given configuration. If the configuration contains a username and password, we assume that the Grafana API is protected via basic auth. If the configuration contains a token we add a token based authentication to each request.

type MockInstance added in v0.8.0

type MockInstance struct {
	mock.Mock
}

MockInstance is an autogenerated mock type for the Instance type

func (*MockInstance) GetDashboard added in v0.8.0

func (_m *MockInstance) GetDashboard(ctx context.Context, uid string) (*Dashboard, error)

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

func (*MockInstance) GetDashboards added in v0.8.0

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

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

func (*MockInstance) GetName added in v0.8.0

func (_m *MockInstance) GetName() string

GetName provides a mock function with given fields:

type ResponseError

type ResponseError struct {
	Message string `json:"message"`
}

ResponseError is the structure of failed Grafana API call.

type SingleDashboardResponse

type SingleDashboardResponse struct {
	Dashboard DashboardData     `json:"dashboard"`
	Metadata  DashboardMetadata `json:"meta"`
}

SingleDashboardResponse is the structure of the data returned by the Grafana API to get a dashboard by its uid.

Jump to

Keyboard shortcuts

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