Skip to content
This repository was archived by the owner on Jan 15, 2024. It is now read-only.

Commit b33991a

Browse files
committed
put back the method for creating API keys through cloud
1 parent 257686c commit b33991a

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

cloud_grafana_api_key.go

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package gapi
2+
3+
import (
4+
"bytes"
5+
"encoding/json"
6+
"fmt"
7+
)
8+
9+
// This function creates a API key inside the Grafana instance running in stack `stack`. It's used in order
10+
// to provision API keys inside Grafana while just having access to a Grafana Cloud API key.
11+
//
12+
// See https://grafana.com/docs/grafana-cloud/api/#create-grafana-api-keys for more information.
13+
func (c *Client) CreateGrafanaAPIKeyFromCloud(stack string, input *CreateAPIKeyRequest) (*CreateAPIKeyResponse, error) {
14+
data, err := json.Marshal(input)
15+
if err != nil {
16+
return nil, err
17+
}
18+
19+
resp := &CreateAPIKeyResponse{}
20+
err = c.request("POST", fmt.Sprintf("/api/instances/%s/api/auth/keys", stack), nil, bytes.NewBuffer(data), resp)
21+
return resp, err
22+
}

0 commit comments

Comments
 (0)