-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathautomation_credentials.go
More file actions
36 lines (30 loc) · 1.17 KB
/
automation_credentials.go
File metadata and controls
36 lines (30 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package api
import (
"context"
"encoding/json"
"fmt"
"net/http"
"gopkg.in/nullstone-io/go-api-client.v0/response"
"gopkg.in/nullstone-io/go-api-client.v0/types"
)
type AutomationCredentials struct {
Client *Client
}
func (s AutomationCredentials) path(stackId, blockId, envId int64) string {
return fmt.Sprintf("orgs/%s/stacks/%d/blocks/%d/envs/%d/automation_credentials", s.Client.Config.OrgName, stackId, blockId, envId)
}
type AcquireAutomationCredentialsInput struct {
ProviderType string `json:"providerType"`
Purpose string `json:"purpose"`
OutputNames []string `json:"outputNames"`
OauthScopes []string `json:"oauthScopes,omitempty"`
}
// Acquire - POST /orgs/:orgName/stacks/:stackId/blocks/:blockId/envs/:envId/automation_credentials
func (s AutomationCredentials) Acquire(ctx context.Context, stackId, blockId, envId int64, input AcquireAutomationCredentialsInput) (*types.OutputCredentials, error) {
rawPayload, _ := json.Marshal(input)
res, err := s.Client.Do(ctx, http.MethodPost, s.path(stackId, blockId, envId), nil, nil, json.RawMessage(rawPayload))
if err != nil {
return nil, err
}
return response.ReadJsonPtr[types.OutputCredentials](res)
}