client

package
v0.0.0-...-a4026e4 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDashboardNotFound = errors.New("Dashboard not found")

ErrDashboardNotFound represents an error if dashboard not found.

View Source
var ErrDatasourceNotFound = errors.New("Datasource not found")

ErrDatasourceNotFound represents an error if datasource not found.

Functions

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse checks the API response for errors, and returns them if present. A response is considered an error if it has a status code outside the 2xx range.

Types

type Client

type Client struct {
	BaseURL   *url.URL // Base URL for API requests.
	UserAgent string   // User agent used when communicating with the GitHub API.

	Dashboards  *DashboardsService
	Datasources *DatasourcesService
	// contains filtered or unexported fields
}

A Client manages communication with the Grafana API.

func NewClient

func NewClient(baseURL *url.URL, token string, httpClient *http.Client) *Client

NewClient returns a new Grafana API client. If a nil httpClient is provided, http.DefaultClient will be used. To use API methods which require authentication, provide an http.Client that will perform the authentication for you.

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do sends an API request and returns the API response.

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method string, urlStr string, body interface{}) (*http.Request, error)

NewRequest creates an API request.

type DashboardHit

type DashboardHit struct {
	ID        int64    `json:"id"`
	Title     string   `json:"title"`
	URI       string   `json:"uri"`
	Tags      []string `json:"tags"`
	IsStarred bool     `json:"isStarred"`
}

DashboardHit represents a found by DashboardsService.Search dashboard

type DashboardSearchOptions

type DashboardSearchOptions struct {
	Query     string   `url:"query,omitempty"`
	Tags      []string `url:"tags,omitempty"`
	IsStarred bool     `url:"starred,omitempty"`
	Limit     int      `url:"limit,omitempty"`
}

DashboardSearchOptions specifies the optional parameters to the DashboardsService.Search method.

type DashboardsService

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

DashboardsService communicates with dashboard methods of the Grafana API.

func NewDashboardsService

func NewDashboardsService(client *Client) *DashboardsService

NewDashboardsService returns a new DashboardsService.

func (*DashboardsService) Get

Get fetches a dashboard by given slug.

Grafana API docs: http://docs.grafana.org/http_api/dashboard/#get-dashboard

func (*DashboardsService) Save

func (ds *DashboardsService) Save(ctx context.Context, dashboard *grafana.Dashboard, overwrite bool) error

Save creates a new dashboard or updates existing one.

Grafana API docs: http://docs.grafana.org/http_api/dashboard/#create-update-dashboard

func (*DashboardsService) Search

Search searches dashboards with given criteria

Grafana API docs: http://docs.grafana.org/http_api/dashboard/#search-dashboards

type DatasourcesService

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

DatasourcesService communicates with datasource methods of the Grafana API.

func NewDatasourcesService

func NewDatasourcesService(client *Client) *DatasourcesService

NewDatasourcesService returns a new DatasourcesService.

func (*DatasourcesService) GetAll

GetAll fetches all datasources.

Grafana API docs: http://docs.grafana.org/http_api/data_source/#get-all-datasources

func (*DatasourcesService) GetByID

GetByID fetches datasource by given id.

Grafana API docs: http://docs.grafana.org/http_api/data_source/#get-a-single-data-sources-by-id

func (*DatasourcesService) GetByName

func (s *DatasourcesService) GetByName(ctx context.Context, name string) (*grafana.Datasource, error)

GetByName fetches datasource with given name.

Grafana API docs: http://docs.grafana.org/http_api/data_source/#get-a-single-data-source-by-name

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response
	Message  string
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Jump to

Keyboard shortcuts

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