grafana_sdk

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2023 License: Apache-2.0 Imports: 10 Imported by: 4

README

CI PkgGoDev

grafana-sdk

Grafana Client

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig added in v0.0.2

type AuthConfig struct {
	// The HTTP basic authentication credentials for the targets.
	BasicAuth *BasicAuth
	// The bearer token for the targets.
	BearerToken string
}

AuthConfig configures an HTTP client.

type BasicAuth added in v0.0.2

type BasicAuth struct {
	Username string `yaml:"username" json:"username"`
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

BasicAuth contains basic HTTP authentication credentials.

type Client

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

func NewClient

func NewClient(hostURL string, auth *AuthConfig) (*Client, error)

NewClient initializes client for interacting with an instance of Grafana server; apiKeyOrBasicAuth accepts either 'username:password' basic authentication credentials, or a Grafana API key. If it is an empty string then no authentication is used.

func (*Client) CreateDatasource

func (c *Client) CreateDatasource(ctx context.Context, ds *Datasource) (*GrafanaResponse, error)

func (*Client) DeleteDashboardByUID

func (c *Client) DeleteDashboardByUID(ctx context.Context, uid string) (*GrafanaResponse, error)

DeleteDashboardByUID will delete the grafana dashboard with the given uid

func (*Client) DeleteDatasource

func (c *Client) DeleteDatasource(ctx context.Context, id int) (*GrafanaResponse, error)

func (*Client) GetCurrentOrg

func (c *Client) GetCurrentOrg(ctx context.Context) (*Org, error)

GetCurrentOrg gets current organization. It reflects GET /api/org/ API call.

func (*Client) GetHealth

func (c *Client) GetHealth(ctx context.Context) (*HealthResponse, error)

GetHealth returns the current health status

func (*Client) SetDashboard

func (c *Client) SetDashboard(ctx context.Context, db *GrafanaDashboard) (*GrafanaResponse, error)

SetDashboard will create or update grafana dashboard

func (*Client) UpdateDatasource

func (c *Client) UpdateDatasource(ctx context.Context, ds Datasource) (*GrafanaResponse, error)

type Datasource

type Datasource struct {
	ID                uint        `json:"id"`
	OrgID             uint        `json:"orgId"`
	Name              string      `json:"name"`
	Type              string      `json:"type"`
	Access            string      `json:"access"` // direct or proxy
	URL               string      `json:"url"`
	Password          *string     `json:"password,omitempty"`
	User              *string     `json:"user,omitempty"`
	Database          *string     `json:"database,omitempty"`
	BasicAuth         *bool       `json:"basicAuth,omitempty"`
	BasicAuthUser     *string     `json:"basicAuthUser,omitempty"`
	BasicAuthPassword *string     `json:"basicAuthPassword,omitempty"`
	IsDefault         bool        `json:"isDefault"`
	JSONData          interface{} `json:"jsonData"`
	SecureJSONData    interface{} `json:"secureJsonData"`
}

Datasource as described in the doc http://docs.grafana.org/reference/http_api/#get-all-datasources

type GrafanaDashboard

type GrafanaDashboard struct {
	Dashboard *runtime.RawExtension `json:"dashboard,omitempty"`
	FolderId  int                   `json:"folderId,omitempty"`
	FolderUid string                `json:"FolderUid,omitempty"`
	Message   string                `json:"message,omitempty"`
	Overwrite bool                  `json:"overwrite,omitempty"`
}

type GrafanaResponse

type GrafanaResponse struct {
	ID         *int    `json:"id,omitempty"`
	UID        *string `json:"uid,omitempty"`
	URL        *string `json:"url,omitempty"`
	Title      *string `json:"title,omitempty"`
	Name       *string `json:"name,omitempty"`
	Message    *string `json:"message,omitempty"`
	Status     *string `json:"status,omitempty"`
	Version    *int    `json:"version,omitempty"`
	Slug       *string `json:"slug,omitempty"`
	StatusCode int     `json:"statusCode,omitempty"`
}

type HealthResponse

type HealthResponse struct {
	Commit   string `json:"commit,omitempty"`
	Database string `json:"database,omitempty"`
	Version  string `json:"version,omitempty"`
}

type Org

type Org struct {
	ID   *int    `json:"id,omitempty"`
	Name *string `json:"name,omitempty"`
}

Jump to

Keyboard shortcuts

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