-
Notifications
You must be signed in to change notification settings - Fork 66
/
atlas_key_type.go
54 lines (42 loc) · 1.14 KB
/
atlas_key_type.go
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
package model
import (
"go.mongodb.org/atlas-sdk/v20231115008/admin"
)
type AtlasRoles = string
const (
GroupOwner AtlasRoles = "GROUP_OWNER"
)
type AtlasKeyType struct {
DefaultFullAccessKey bool // use full access key provided with github secrets
Roles []AtlasRoles // specify role for non default
Whitelist []string
GlobalLevelKey bool // if true, tests create "<operator-deployment-name>-api-key"
GlobalKeyAttached *admin.ApiKeyUserDetails
}
func NewEmptyAtlasKeyType() *AtlasKeyType {
return &AtlasKeyType{}
}
func (a *AtlasKeyType) GetRole() []AtlasRoles {
return a.Roles
}
func (a *AtlasKeyType) UseDefaultFullAccess() *AtlasKeyType {
a.DefaultFullAccessKey = true
return a
}
func (a *AtlasKeyType) CreateAsGlobalLevelKey() *AtlasKeyType {
a.GlobalLevelKey = true
return a
}
func (a *AtlasKeyType) WithRoles(r []AtlasRoles) *AtlasKeyType {
a.DefaultFullAccessKey = false
a.Roles = r
return a
}
func (a *AtlasKeyType) WithWhiteList(wl []string) *AtlasKeyType {
a.DefaultFullAccessKey = false
a.Whitelist = wl
return a
}
func (a *AtlasKeyType) IsFullAccess() bool {
return a.DefaultFullAccessKey
}