gapi

package module
v0.0.0-...-0b8430c Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

README

go-grafana-api

Grafana HTTP API Client for Go intended for Terraform Provider CRUD

Tests

To run the tests:

go test

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("404 Not Found")
)

Functions

This section is empty.

Types

type AlertNotification

type AlertNotification struct {
	Id        int64       `json:"id,omitempty"`
	Name      string      `json:"name"`
	Type      string      `json:"type"`
	IsDefault bool        `json:"isDefault"`
	Settings  interface{} `json:"settings"`
}

type Client

type Client struct {
	*http.Client
	// contains filtered or unexported fields
}

func New

func New(auth, baseURL string) (*Client, error)

New creates a new grafana client auth can be in user:pass format, or it can be an api key

func (*Client) AddOrgUser

func (c *Client) AddOrgUser(orgId int64, user, role string) error

func (*Client) AddTeamMember

func (c *Client) AddTeamMember(id string, userID int64) error

func (*Client) AlertNotification

func (c *Client) AlertNotification(id int64) (*AlertNotification, error)

func (*Client) CreateUser

func (c *Client) CreateUser(user User) (int64, error)

func (*Client) Dashboard

func (c *Client) Dashboard(slug string) (*Dashboard, error)

func (*Client) DataSource

func (c *Client) DataSource(id int64) (*DataSource, error)

func (*Client) DeleteAlertNotification

func (c *Client) DeleteAlertNotification(id int64) error

func (*Client) DeleteDashboard

func (c *Client) DeleteDashboard(slug string) error

func (*Client) DeleteDataSource

func (c *Client) DeleteDataSource(id int64) error

func (*Client) DeleteFolder

func (c *Client) DeleteFolder(id string) error

func (*Client) DeleteOrg

func (c *Client) DeleteOrg(id int64) error

func (*Client) DeleteTeam

func (c *Client) DeleteTeam(id string) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(id int64) error

func (*Client) Folder

func (c *Client) Folder(id int64) (*Folder, error)

func (*Client) Folders

func (c *Client) Folders() ([]Folder, error)

func (*Client) NewAlertNotification

func (c *Client) NewAlertNotification(a *AlertNotification) (int64, error)

func (*Client) NewDashboard

func (c *Client) NewDashboard(dashboard Dashboard) (*DashboardSaveResponse, error)

func (*Client) NewDataSource

func (c *Client) NewDataSource(s *DataSource) (int64, error)

func (*Client) NewFolder

func (c *Client) NewFolder(title string) (Folder, error)

func (*Client) NewOrg

func (c *Client) NewOrg(name string) (int64, error)

func (*Client) NewTeam

func (c *Client) NewTeam(name string) (*Team, error)

func (*Client) Org

func (c *Client) Org(id int64) (Org, error)

func (*Client) OrgByName

func (c *Client) OrgByName(name string) (Org, error)

func (*Client) OrgUsers

func (c *Client) OrgUsers(orgId int64) ([]OrgUser, error)

func (*Client) Orgs

func (c *Client) Orgs() ([]Org, error)

func (*Client) RemoveOrgUser

func (c *Client) RemoveOrgUser(orgId, userId int64) error

func (*Client) RemoveTeamMember

func (c *Client) RemoveTeamMember(id string, userID int64) error

func (*Client) SaveDashboard deprecated

func (c *Client) SaveDashboard(model map[string]interface{}, overwrite bool) (*DashboardSaveResponse, error)

Deprecated: use NewDashboard instead

func (*Client) Team

func (c *Client) Team(id int64) (*Team, error)

func (*Client) TeamMembers

func (c *Client) TeamMembers(id string) ([]*TeamMember, error)

func (*Client) Teams

func (c *Client) Teams() ([]*Team, error)

func (*Client) UpdateAlertNotification

func (c *Client) UpdateAlertNotification(a *AlertNotification) error

func (*Client) UpdateDataSource

func (c *Client) UpdateDataSource(s *DataSource) error

func (*Client) UpdateFolder

func (c *Client) UpdateFolder(id string, name string) error

func (*Client) UpdateOrg

func (c *Client) UpdateOrg(id int64, name string) error

func (*Client) UpdateOrgUser

func (c *Client) UpdateOrgUser(orgId, userId int64, role string) error

func (*Client) UpdateTeam

func (c *Client) UpdateTeam(id string, name string, email string) error

func (*Client) UserByEmail

func (c *Client) UserByEmail(email string) (User, error)

func (*Client) Users

func (c *Client) Users() ([]User, error)

type CreateTeamResponse

type CreateTeamResponse struct {
	Id int64 `json:"teamId"`
}

type Dashboard

type Dashboard struct {
	Meta      DashboardMeta          `json:"meta"`
	Model     map[string]interface{} `json:"dashboard"`
	Folder    int64                  `json:"folderId"`
	Overwrite bool                   `json:overwrite`
}

type DashboardMeta

type DashboardMeta struct {
	IsStarred bool   `json:"isStarred"`
	Slug      string `json:"slug"`
	Folder    int64  `json:"folderId"`
}

type DashboardSaveResponse

type DashboardSaveResponse struct {
	Slug    string `json:"slug"`
	Id      int64  `json:"id"`
	Uid     string `json:"uid"`
	Status  string `json:"status"`
	Version int64  `json:"version"`
}

type DataSource

type DataSource struct {
	Id     int64  `json:"id,omitempty"`
	Name   string `json:"name"`
	Type   string `json:"type"`
	URL    string `json:"url"`
	Access string `json:"access"`

	Database string `json:"database,omitempty"`
	User     string `json:"user,omitempty"`
	Password string `json:"password,omitempty"`

	OrgId     int64 `json:"orgId,omitempty"`
	IsDefault bool  `json:"isDefault"`

	BasicAuth         bool   `json:"basicAuth"`
	BasicAuthUser     string `json:"basicAuthUser,omitempty"`
	BasicAuthPassword string `json:"basicAuthPassword,omitempty"`

	JSONData       JSONData       `json:"jsonData,omitempty"`
	SecureJSONData SecureJSONData `json:"secureJsonData,omitempty"`
}

type Folder

type Folder struct {
	Id    int64  `json:"id"`
	Uid   string `json:"uid"`
	Title string `json:"title"`
}

type JSONData

type JSONData struct {
	AssumeRoleArn           string `json:"assumeRoleArn,omitempty"`
	AuthType                string `json:"authType,omitempty"`
	CustomMetricsNamespaces string `json:"customMetricsNamespaces,omitempty"`
	DefaultRegion           string `json:"defaultRegion,omitempty"`
	TlsSkipVerify           bool   `json:"tlsSkipVerify,omitempty"`
}

JSONData is a representation of the datasource `jsonData` property

type Org

type Org struct {
	Id   int64  `json:"id"`
	Name string `json:"name"`
}

type OrgUser

type OrgUser struct {
	OrgId  int64  `json:"orgId"`
	UserId int64  `json:"userId"`
	Email  string `json:"email"`
	Login  string `json:"login"`
	Role   string `json:"role"`
}

type SecureJSONData

type SecureJSONData struct {
	AccessKey string `json:"accessKey,omitempty"`
	SecretKey string `json:"secretKey,omitempty"`
}

SecureJSONData is a representation of the datasource `secureJsonData` property

type Team

type Team struct {
	Id          int64  `json:"id,omitempty"`
	OrgId       int64  `json:"orgId,omitempty"`
	Name        string `json:"name,omitempty"`
	Email       string `json:"email,omitempty"`
	AvatarUrl   string `json:"avatarUrl,omitempty"`
	MemberCount int64  `json:"memberCount,omitempty"`
}

type TeamMember

type TeamMember struct {
	UserId    int64  `json:"userId,omitempty"`
	TeamId    int64  `json:"teamId,omitempty"`
	OrgId     int64  `json:"orgId,omitempty"`
	Login     string `json:"login,omitempty"`
	Email     string `json:"email,omitempty"`
	AvatarUrl string `json:"avatarUrl,omitempty"`
}

type TeamSearchResponse

type TeamSearchResponse struct {
	TotalCount int64   `json:"totalCount,omitempty"`
	Teams      []*Team `json:"teams,omitempty"`
	Page       int64   `json:"page,omitempty"`
	PerPage    int64   `json:"perPage,omitempty"`
}

type User

type User struct {
	Id       int64  `json:"id,omitempty"`
	Email    string `json:"email,omitempty"`
	Name     string `json:"name,omitempty"`
	Login    string `json:"login,omitempty"`
	Password string `json:"password,omitempty"`
	IsAdmin  bool   `json:"isAdmin,omitempty"`
}

Jump to

Keyboard shortcuts

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