github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/vaults/bind_policy.go (about) 1 package vaults 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type BindPolicyOpts struct { 9 PolicyID string `json:"policy_id"` 10 } 11 12 func BindPolicy(client *golangsdk.ServiceClient, vaultID string, opts BindPolicyOpts) (*PolicyBinding, error) { 13 b, err := golangsdk.BuildRequestBody(opts, "") 14 if err != nil { 15 return nil, err 16 } 17 18 raw, err := client.Post(client.ServiceURL("vaults", vaultID, "associatepolicy"), b, nil, &golangsdk.RequestOpts{ 19 OkCodes: []int{200}, 20 }) 21 if err != nil { 22 return nil, err 23 } 24 25 var res PolicyBinding 26 return &res, extract.IntoStructPtr(raw.Body, &res, "associate_policy") 27 } 28 29 type PolicyBinding struct { 30 VaultID string `json:"vault_id"` 31 PolicyID string `json:"policy_id"` 32 }