Documentation
¶
Overview ¶
Package cloud provides clients for Grafana Cloud platform APIs.
Index ¶
- type CreateStackRequest
- type GCOMClient
- func (c *GCOMClient) CreateStack(ctx context.Context, r CreateStackRequest) (StackInfo, error)
- func (c *GCOMClient) DeleteStack(ctx context.Context, slug string) error
- func (c *GCOMClient) GetStack(ctx context.Context, slug string) (StackInfo, error)
- func (c *GCOMClient) ListRegions(ctx context.Context) ([]Region, error)
- func (c *GCOMClient) ListStacks(ctx context.Context, orgSlug string) ([]StackInfo, error)
- func (c *GCOMClient) UpdateStack(ctx context.Context, slug string, r UpdateStackRequest) (StackInfo, error)
- type GCOMHTTPError
- type Region
- type StackInfo
- type UpdateStackRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateStackRequest ¶ added in v0.2.13
type CreateStackRequest struct {
Name string `json:"name"`
Slug string `json:"slug"`
URL string `json:"url,omitempty"`
Region string `json:"region,omitempty"`
Description string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
DeleteProtection *bool `json:"deleteProtection,omitempty"`
}
CreateStackRequest is the request body for creating a new Grafana Cloud stack.
type GCOMClient ¶
type GCOMClient struct {
// contains filtered or unexported fields
}
GCOMClient is an HTTP client for the Grafana Cloud API (GCOM).
func NewGCOMClient ¶
func NewGCOMClient(baseURL, token string) (*GCOMClient, error)
NewGCOMClient returns a new GCOMClient configured to call the given base URL using the provided Bearer token.
The client uses a 30-second timeout and will not follow HTTP redirects to a different domain than baseURL.
func (*GCOMClient) CreateStack ¶ added in v0.2.13
func (c *GCOMClient) CreateStack(ctx context.Context, r CreateStackRequest) (StackInfo, error)
CreateStack calls POST /api/instances on the GCOM API to create a new stack.
func (*GCOMClient) DeleteStack ¶ added in v0.2.13
func (c *GCOMClient) DeleteStack(ctx context.Context, slug string) error
DeleteStack calls DELETE /api/instances/{slug} on the GCOM API. Returns a GCOMHTTPError with Status 409 when delete protection is enabled.
func (*GCOMClient) GetStack ¶
GetStack calls GET /api/instances/{slug} on the GCOM API and returns the corresponding StackInfo. It returns an error if the response status is not 200.
func (*GCOMClient) ListRegions ¶ added in v0.2.13
func (c *GCOMClient) ListRegions(ctx context.Context) ([]Region, error)
ListRegions calls GET /api/stack-regions on the GCOM API and returns the available regions for stack creation.
func (*GCOMClient) ListStacks ¶ added in v0.2.13
ListStacks calls GET /api/orgs/{orgSlug}/instances on the GCOM API and returns the stacks belonging to the given organisation.
func (*GCOMClient) UpdateStack ¶ added in v0.2.13
func (c *GCOMClient) UpdateStack(ctx context.Context, slug string, r UpdateStackRequest) (StackInfo, error)
UpdateStack calls POST /api/instances/{slug} on the GCOM API to update a stack.
type GCOMHTTPError ¶ added in v0.2.12
GCOMHTTPError is returned by GCOMClient when the GCOM API responds with a non-200 status. Callers can use errors.As to inspect Status and dispatch on 401/403/404 etc. without parsing the error message.
func (*GCOMHTTPError) Error ¶ added in v0.2.12
func (e *GCOMHTTPError) Error() string
type Region ¶ added in v0.2.13
type Region struct {
ID int `json:"id"`
Status string `json:"status"`
Slug string `json:"slug"`
Name string `json:"name"`
Description string `json:"description"`
Provider string `json:"provider"`
CreatedAt string `json:"createdAt,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
}
Region describes a Grafana Cloud stack region as returned by the GCOM API.
type StackInfo ¶
type StackInfo struct {
ID int `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
URL string `json:"url"`
OrgID int `json:"orgId"`
OrgSlug string `json:"orgSlug"`
Status string `json:"status"`
RegionSlug string `json:"regionSlug"`
// Stack metadata (returned by list/create/update/get).
Type string `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
DeleteProtection bool `json:"deleteProtection,omitempty"`
Plan string `json:"plan,omitempty"`
PlanName string `json:"planName,omitempty"`
ClusterSlug string `json:"clusterSlug,omitempty"`
RunningVersion string `json:"runningVersion,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
CreatedBy string `json:"createdBy,omitempty"`
UpdatedAt string `json:"updatedAt,omitempty"`
UpdatedBy string `json:"updatedBy,omitempty"`
// Prometheus (Hosted Metrics)
HMInstancePromID int `json:"hmInstancePromId"`
HMInstancePromURL string `json:"hmInstancePromUrl"`
HMInstancePromClusterID int `json:"hmInstancePromClusterId"`
// Loki (Hosted Logs)
HLInstanceID int `json:"hlInstanceId"`
HLInstanceURL string `json:"hlInstanceUrl"`
// Tempo (Hosted Traces)
HTInstanceID int `json:"htInstanceId"`
HTInstanceURL string `json:"htInstanceUrl"`
// Pyroscope (Hosted Profiles)
HPInstanceID int `json:"hpInstanceId"`
HPInstanceURL string `json:"hpInstanceUrl"`
// Fleet Management (Agent Management)
AgentManagementInstanceID int `json:"agentManagementInstanceId"`
AgentManagementInstanceURL string `json:"agentManagementInstanceUrl"`
// Alertmanager
AMInstanceID int `json:"amInstanceId"`
AMInstanceURL string `json:"amInstanceUrl"`
}
StackInfo holds the information about a Grafana Cloud stack as returned by the GCOM API.
type UpdateStackRequest ¶ added in v0.2.13
type UpdateStackRequest struct {
Name string `json:"name,omitempty"`
Description *string `json:"description,omitempty"`
Labels map[string]string `json:"labels,omitempty"`
DeleteProtection *bool `json:"deleteProtection,omitempty"`
}
UpdateStackRequest is the request body for updating a Grafana Cloud stack.