Documentation ¶
Index ¶
- type AuthConfig
- type BasicAuth
- type Client
- func (c *Client) CreateDatasource(ctx context.Context, ds *Datasource) (*GrafanaResponse, error)
- func (c *Client) DeleteDashboardByUID(ctx context.Context, uid string) (*GrafanaResponse, error)
- func (c *Client) DeleteDatasource(ctx context.Context, id int) (*GrafanaResponse, error)
- func (c *Client) GetCurrentOrg(ctx context.Context) (*Org, error)
- func (c *Client) GetHealth(ctx context.Context) (*HealthResponse, error)
- func (c *Client) SetDashboard(ctx context.Context, db *GrafanaDashboard) (*GrafanaResponse, error)
- func (c *Client) UpdateDatasource(ctx context.Context, ds Datasource) (*GrafanaResponse, error)
- type Datasource
- type GrafanaDashboard
- type GrafanaResponse
- type HealthResponse
- type Org
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, httpClient *resty.Client) (*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 ¶
DeleteDashboardByUID will delete the grafana dashboard with the given uid
func (*Client) DeleteDatasource ¶
func (*Client) GetCurrentOrg ¶
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 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"` }