Documentation ¶
Index ¶
- Variables
- func CheckResponse(r *http.Response) error
- type Client
- type DashboardHit
- type DashboardSearchOptions
- type DashboardsService
- func (ds *DashboardsService) Get(ctx context.Context, slug string) (*grafana.Dashboard, error)
- func (ds *DashboardsService) Save(ctx context.Context, dashboard *grafana.Dashboard, overwrite bool) error
- func (ds *DashboardsService) Search(ctx context.Context, opt *DashboardSearchOptions) ([]*DashboardHit, error)
- type DatasourcesService
- func (s *DatasourcesService) GetAll(ctx context.Context) ([]*grafana.Datasource, error)
- func (s *DatasourcesService) GetByID(ctx context.Context, id grafana.DatasourceID) (*grafana.Datasource, error)
- func (s *DatasourcesService) GetByName(ctx context.Context, name string) (*grafana.Datasource, error)
- type ErrorResponse
Constants ¶
This section is empty.
Variables ¶
var ErrDashboardNotFound = errors.New("Dashboard not found")
ErrDashboardNotFound represents an error if dashboard not found.
var ErrDatasourceNotFound = errors.New("Datasource not found")
ErrDatasourceNotFound represents an error if datasource not found.
Functions ¶
func CheckResponse ¶
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 ¶
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.
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 ¶
func (ds *DashboardsService) Search(ctx context.Context, opt *DashboardSearchOptions) ([]*DashboardHit, error)
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 ¶
func (s *DatasourcesService) GetAll(ctx context.Context) ([]*grafana.Datasource, error)
GetAll fetches all datasources.
Grafana API docs: http://docs.grafana.org/http_api/data_source/#get-all-datasources
func (*DatasourcesService) GetByID ¶
func (s *DatasourcesService) GetByID(ctx context.Context, id grafana.DatasourceID) (*grafana.Datasource, error)
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 ¶
func (*ErrorResponse) Error ¶
func (r *ErrorResponse) Error() string