instance

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2023 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 {
	Address  string `json:"address"`
	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)
}

func New

func New(name string, options map[string]any) (Instance, error)

New returns a new Grafana instance for the given configuration.

type MockInstance

type MockInstance struct {
	mock.Mock
}

MockInstance is an autogenerated mock type for the Instance type

func NewMockInstance

func NewMockInstance(t NewMockInstanceT) *MockInstance

NewMockInstance creates a new instance of MockInstance. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*MockInstance) GetDashboard

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

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

func (*MockInstance) GetDashboardEmbed

func (_m *MockInstance) GetDashboardEmbed(ctx context.Context, dashboardID string, queryParameter string) ([]byte, error)

GetDashboardEmbed provides a mock function with given fields: ctx, dashboardID, queryParameter

func (*MockInstance) GetDashboardFile

func (_m *MockInstance) GetDashboardFile(ctx context.Context, file string) ([]byte, error)

GetDashboardFile provides a mock function with given fields: ctx, file

func (*MockInstance) GetDashboards

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

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

func (*MockInstance) GetName

func (_m *MockInstance) GetName() string

GetName provides a mock function with given fields:

func (*MockInstance) Proxy

func (_m *MockInstance) Proxy(w http.ResponseWriter, r *http.Request, dashboardID string, queryParameter string)

Proxy provides a mock function with given fields: w, r, dashboardID, queryParameter

type NewMockInstanceT

type NewMockInstanceT interface {
	mock.TestingT
	Cleanup(func())
}

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