github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/container/containerv1/kms.go (about) 1 package containerv1 2 3 import ( 4 "github.com/IBM-Cloud/bluemix-go/client" 5 ) 6 7 const ( 8 account = "X-Auth-Resource-Account" 9 resourceGroup = "X-Auth-Resource-Group" 10 ) 11 12 // Request body to attach a KMS to a cluster 13 type KmsEnableReq struct { 14 AccountID string `json:"account_id,omitempty"` 15 Cluster string `json:"cluster"` 16 Crk string `json:"crk_id"` 17 Kms string `json:"instance_id"` 18 PrivateEndpoint bool `json:"private_endpoint"` 19 } 20 21 // ClusterHeader ... 22 type ClusterHeader struct { 23 AccountID string 24 ResourceGroup string 25 } 26 27 // CreateMap ... 28 func (c ClusterHeader) CreateMap() map[string]string { 29 m := make(map[string]string, 3) 30 m[account] = c.AccountID 31 m[resourceGroup] = c.ResourceGroup 32 return m 33 } 34 35 type kms struct { 36 client *client.Client 37 } 38 39 // Kms interface 40 type Kms interface { 41 EnableKms(enableKmsReq KmsEnableReq, target ClusterHeader) error 42 } 43 44 func newKmsAPI(c *client.Client) Kms { 45 return &kms{ 46 client: c, 47 } 48 } 49 50 func (r *kms) EnableKms(enableKmsReq KmsEnableReq, target ClusterHeader) error { 51 _, err := r.client.Post("/v2/enableKMS", enableKmsReq, nil, target.CreateMap()) 52 return err 53 }