-
Notifications
You must be signed in to change notification settings - Fork 36
Expand file tree
/
Copy pathcommon.go
More file actions
91 lines (79 loc) · 1.72 KB
/
common.go
File metadata and controls
91 lines (79 loc) · 1.72 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package dbt_cloud
import (
"encoding/json"
"fmt"
"net/http"
"github.com/samber/lo"
)
const (
STATE_ACTIVE = 1
STATE_DELETED = 2
ID_DELIMITER = ":"
NUM_THREADS_CREDENTIAL = 6
)
var (
PermissionSets = []string{
"owner",
"member",
"account_admin",
"security_admin",
"billing_admin",
"admin",
"database_admin",
"git_admin",
"team_admin",
"job_admin",
"job_runner",
"job_viewer",
"analyst",
"developer",
"stakeholder",
"readonly",
"project_creator",
"account_viewer",
"metadata_only",
"semantic_layer_only",
"webhooks_only",
"fusion_admin",
"cost_management_viewer",
"cost_management_admin",
"manage_marketplace_apps",
"notification_manager",
}
)
// This is not used now but allows us to find the list of permission sets allowed
// Terraform doesn't allow to run it in the offline validation mode though as we don't have access to the configuration context
type ConstantsResponse struct {
Data Constants `json:"data"`
Status ResponseStatus `json:"status"`
}
type Constants struct {
PermissionSets map[string]string `json:"permissions_sets"`
}
func (c *Client) GetConstants() (*Constants, error) {
req, err := http.NewRequest(
"GET",
fmt.Sprintf("%s/v2/constants/", c.HostURL),
nil,
)
if err != nil {
return nil, err
}
body, err := c.doRequestWithRetry(req)
if err != nil {
return nil, err
}
constantsResponse := ConstantsResponse{}
err = json.Unmarshal(body, &constantsResponse)
if err != nil {
return nil, err
}
return &constantsResponse.Data, nil
}
func (c *Client) GetPermissionIDs() ([]string, error) {
constants, err := c.GetConstants()
if err != nil {
return nil, err
}
return lo.Keys(constants.PermissionSets), nil
}