github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/vaults/update.go (about)

     1  package vaults
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/extract"
     6  	"github.com/opentelekomcloud/gophertelekomcloud/openstack/common/tags"
     7  )
     8  
     9  type BillingUpdate struct {
    10  	Size int `json:"size,omitempty"`
    11  }
    12  
    13  type VaultBindRules struct {
    14  	// Filters automatically associated resources by tag.
    15  	Tags []tags.ResourceTag `json:"tags,omitempty"`
    16  }
    17  
    18  type UpdateOpts struct {
    19  	Billing    *BillingUpdate  `json:"billing,omitempty"`
    20  	Name       string          `json:"name,omitempty"`
    21  	AutoBind   *bool           `json:"auto_bind,omitempty"`
    22  	BindRules  *VaultBindRules `json:"bind_rules,omitempty"`
    23  	AutoExpand *bool           `json:"auto_expand,omitempty"`
    24  }
    25  
    26  func Update(client *golangsdk.ServiceClient, id string, opts UpdateOpts) (*Vault, error) {
    27  	b, err := golangsdk.BuildRequestBody(opts, "vault")
    28  	if err != nil {
    29  		return nil, err
    30  	}
    31  
    32  	raw, err := client.Put(client.ServiceURL("vaults", id), b, nil, &golangsdk.RequestOpts{
    33  		OkCodes: []int{200},
    34  	})
    35  	if err != nil {
    36  		return nil, err
    37  	}
    38  
    39  	var res Vault
    40  	return &res, extract.IntoStructPtr(raw.Body, &res, "vault")
    41  }