/
kms.go
53 lines (44 loc) · 1.12 KB
/
kms.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
package containerv1
import (
"github.com/IBM-Cloud/bluemix-go/client"
)
const (
account = "X-Auth-Resource-Account"
resourceGroup = "X-Auth-Resource-Group"
)
// Request body to attach a KMS to a cluster
type KmsEnableReq struct {
AccountID string `json:"account_id,omitempty"`
Cluster string `json:"cluster"`
Crk string `json:"crk_id"`
Kms string `json:"instance_id"`
PrivateEndpoint bool `json:"private_endpoint"`
}
// ClusterHeader ...
type ClusterHeader struct {
AccountID string
ResourceGroup string
}
// CreateMap ...
func (c ClusterHeader) CreateMap() map[string]string {
m := make(map[string]string, 3)
m[account] = c.AccountID
m[resourceGroup] = c.ResourceGroup
return m
}
type kms struct {
client *client.Client
}
// Kms interface
type Kms interface {
EnableKms(enableKmsReq KmsEnableReq, target ClusterHeader) error
}
func newKmsAPI(c *client.Client) Kms {
return &kms{
client: c,
}
}
func (r *kms) EnableKms(enableKmsReq KmsEnableReq, target ClusterHeader) error {
_, err := r.client.Post("/v2/enableKMS", enableKmsReq, nil, target.CreateMap())
return err
}