Skip to content

Latest commit

 

History

History
286 lines (239 loc) · 17.4 KB

README.md

File metadata and controls

286 lines (239 loc) · 17.4 KB

Go API client for gcom

Grafana.com API (public).

Looking for GCOM API client packages? You can find them at grafana-com-public-clients repository.

If you have any questions, please contact support in the Grafana Cloud UI.

This spec is in Beta stage, so use it with caution:

  • Not all endpoint responses are properly typed for the time being.
  • Some request parameter types may not be precise

Overview

This API client was generated by the OpenAPI Generator project. By using the OpenAPI-spec from a remote server, you can easily generate an API client.

  • API version: public
  • Package version: 1.0.0
  • Generator version: 7.7.0
  • Build package: org.openapitools.codegen.languages.GoClientCodegen

Installation

Install the following dependencies:

go get github.com/stretchr/testify/assert
go get golang.org/x/net/context

Put the package under your project folder and add the following in import:

import gcom "github.com/grafana/grafana-com-public-clients/go/gcom"

To use a proxy, set the environment variable HTTP_PROXY:

os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")

Configuration of Server URL

Default configuration comes with Servers field that contains server objects as defined in the OpenAPI specification.

Select Server Configuration

For using other server than the one defined on index 0 set context value gcom.ContextServerIndex of type int.

ctx := context.WithValue(context.Background(), gcom.ContextServerIndex, 1)

Templated Server URL

Templated server URL is formatted using default variables from configuration or from context value gcom.ContextServerVariables of type map[string]string.

ctx := context.WithValue(context.Background(), gcom.ContextServerVariables, map[string]string{
	"basePath": "v2",
})

Note, enum values are always validated and all unused variables are silently ignored.

URLs Configuration per Operation

Each operation can use different server URL defined using OperationServers map in the Configuration. An operation is uniquely identified by "{classname}Service.{nickname}" string. Similar rules for overriding default operation server index and variables applies by using gcom.ContextOperationServerIndices and gcom.ContextOperationServerVariables context maps.

ctx := context.WithValue(context.Background(), gcom.ContextOperationServerIndices, map[string]int{
	"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), gcom.ContextOperationServerVariables, map[string]map[string]string{
	"{classname}Service.{nickname}": {
		"port": "8443",
	},
})

Documentation for API Endpoints

All URIs are relative to /api

Class Method HTTP request Description
AccesspoliciesAPI DeleteAccessPolicy Delete /v1/accesspolicies/{id} Delete an access policy
AccesspoliciesAPI GetAccessPolicies Get /v1/accesspolicies Get a list of access policies
AccesspoliciesAPI GetAccessPolicy Get /v1/accesspolicies/{id} Get an access policy
AccesspoliciesAPI GetConfig Get /v1/accesspolicies/config Get details about the Cloud Access Policy API
AccesspoliciesAPI PostAccessPolicies Post /v1/accesspolicies Create a new access policy
AccesspoliciesAPI PostAccessPolicy Post /v1/accesspolicies/{id} Update an access policy
InstancesAPI DelInstanceOAuthAzureAD Delete /instances/{instanceId}/oauth-azuread Disable Azure OAuth in an instance
InstancesAPI DelInstanceOAuthGithub Delete /instances/{instanceId}/oauth-github Disable Github OAuth in an instance
InstancesAPI DelInstanceOAuthGoogle Delete /instances/{instanceId}/oauth-google Disable Google OAuth in an instance
InstancesAPI DelInstanceOAuthOkta Delete /instances/{instanceId}/oauth-okta Disable Okta OAuth in an instance
InstancesAPI DeleteInstance Delete /instances/{instanceId} Deletes an instance
InstancesAPI DeleteInstancePlugin Delete /instances/{instanceId}/plugins/{pluginSlugOrId}
InstancesAPI DeleteInstanceServiceAccount Delete /instances/{instanceId}/api/serviceaccounts/{serviceAccountId} Delete a service account on a Grafana instance
InstancesAPI DeleteInstanceServiceAccountToken Delete /instances/{instanceId}/api/serviceaccounts/{serviceAccountId}/tokens/{tokenId} Delete a service account token on a Grafana instance
InstancesAPI GetConnections Get /instances/{instanceId}/connections Gets an instance's connectivity information (InfluxDB, OTEL, AWS private link, etc.)
InstancesAPI GetInstance Get /instances/{instanceId} Gets an instance
InstancesAPI GetInstancePlugin Get /instances/{instanceId}/plugins/{pluginSlugOrId}
InstancesAPI GetInstancePlugins Get /instances/{instanceId}/plugins
InstancesAPI GetInstanceServiceAccount Get /instances/{instanceId}/api/serviceaccounts/{serviceAccountId} Gets a service account on a Grafana instance
InstancesAPI GetInstanceServiceAccountTokens Get /instances/{instanceId}/api/serviceaccounts/{serviceAccountId}/tokens Get a service account's tokens on a Grafana instance
InstancesAPI GetInstanceUsers Get /instances/{instanceId}/users Gets instance active users
InstancesAPI GetInstances Get /instances Get a list of instances
InstancesAPI PostInstance Post /instances/{instanceId} Updates an instance
InstancesAPI PostInstanceOAuthAzureAD Post /instances/{instanceId}/oauth-azuread Configure Azure OAuth in an instance
InstancesAPI PostInstanceOAuthGithub Post /instances/{instanceId}/oauth-github Configure Github OAuth in an instance
InstancesAPI PostInstanceOAuthGoogle Post /instances/{instanceId}/oauth-google Configure Google OAuth in an instance
InstancesAPI PostInstanceOAuthOkta Post /instances/{instanceId}/oauth-okta Configure Okta OAuth in an instance
InstancesAPI PostInstancePlugin Post /instances/{instanceId}/plugins/{pluginSlugOrId}
InstancesAPI PostInstancePlugins Post /instances/{instanceId}/plugins
InstancesAPI PostInstanceServiceAccountTokens Post /instances/{instanceId}/api/serviceaccounts/{serviceAccountId}/tokens Creates a service account token on a Grafana instance
InstancesAPI PostInstanceServiceAccounts Post /instances/{instanceId}/api/serviceaccounts Creates a service account on a Grafana instance
InstancesAPI PostInstances Post /instances Create a new instance
OrgsAPI CheckOrgVisibility Get /orgs/{slugOrId}/check-visibility
OrgsAPI DelApiKey Delete /orgs/{slugOrId}/api-keys/{name} Delete an API key by name
OrgsAPI DeleteOrgMember Delete /orgs/{slugOrId}/members/{usernameOrId}
OrgsAPI GetApiKey Get /orgs/{slugOrId}/api-keys/{name} Get an API key by name
OrgsAPI GetApiKeys Get /orgs/{slugOrId}/api-keys Get an organization's API keys
OrgsAPI GetOrg Get /orgs/{slugOrId}
OrgsAPI GetOrgBilledUsage Get /orgs/{orgSlugOrId}/billed-usage Retrieve an org's billed usage for a specific month
OrgsAPI GetOrgBilledUsageHistory Get /orgs/{orgSlugOrId}/billed-usage-history Retrieve an org's billed usage items for the last 12 months
OrgsAPI GetOrgInstances Get /orgs/{orgSlug}/instances Get the list of instances belonging to the org
OrgsAPI GetOrgMember Get /orgs/{slugOrId}/members/{usernameOrId}
OrgsAPI GetOrgMembers Get /orgs/{slugOrId}/members
OrgsAPI PostApiKeys Post /orgs/{slugOrId}/api-keys Create an API key.
OrgsAPI PostOrgMember Post /orgs/{slugOrId}/members/{usernameOrId}
OrgsAPI PostOrgMembers Post /orgs/{slugOrId}/members
PluginsAPI GetPlugin Get /plugins/{slug} Fetches a plugin by slug or id
StackRegionsAPI GetClosestStackRegion Get /stack-regions/closest
StackRegionsAPI GetStackRegions Get /stack-regions
TokensAPI DeleteToken Delete /v1/tokens/{id} Delete a token
TokensAPI GetToken Get /v1/tokens/{id} Get info for a specific token
TokensAPI GetTokens Get /v1/tokens Get a list of tokens
TokensAPI PostToken Post /v1/tokens/{id} Update a token
TokensAPI PostTokens Post /v1/tokens Create a new token

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

BearerAuth

  • Type: HTTP Bearer token authentication

Example

auth := context.WithValue(context.Background(), gcom.ContextAccessToken, "BEARER_TOKEN_STRING")
r, err := client.Service.Operation(auth, args)

Documentation for Utility Methods

Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:

  • PtrBool
  • PtrInt
  • PtrInt32
  • PtrInt64
  • PtrFloat
  • PtrFloat32
  • PtrFloat64
  • PtrString
  • PtrTime

Author