github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/cbr/v3/vaults/associate_resources.go (about) 1 package vaults 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ResourceExtraInfoIncludeVolumes struct { 9 // EVS disk ID. Only UUID is supported. 10 ID string `json:"id"` 11 // OS type 12 OSVersion string `json:"os_version,omitempty"` 13 } 14 15 type ResourceExtraInfo struct { 16 // ID of the disk that is excluded from the backup. 17 // This parameter is used only when there are VM disk backups. 18 ExcludeVolumes []string `json:"exclude_volumes,omitempty"` 19 // Disk to be backed up 20 IncludeVolumes []ResourceExtraInfoIncludeVolumes `json:"include_volumes,omitempty"` 21 } 22 23 type ResourceCreate struct { 24 // ID of the resource to be backed up 25 ID string `json:"id"` 26 // Type of the resource to be backed up. 27 // Possible values are `OS::Nova::Server` and `OS::Cinder::Volume` 28 Type string `json:"type"` 29 // Resource name 30 Name string `json:"name,omitempty"` 31 // Extra information of the resource 32 ExtraInfo *ResourceExtraInfo `json:"extra_info,omitempty"` 33 } 34 35 type AssociateResourcesOpts struct { 36 Resources []ResourceCreate `json:"resources"` 37 } 38 39 func AssociateResources(client *golangsdk.ServiceClient, vaultID string, opts AssociateResourcesOpts) ([]string, error) { 40 b, err := golangsdk.BuildRequestBody(opts, "") 41 if err != nil { 42 return nil, err 43 } 44 45 raw, err := client.Post(client.ServiceURL("vaults", vaultID, "addresources"), b, nil, &golangsdk.RequestOpts{ 46 OkCodes: []int{200}, 47 }) 48 if err != nil { 49 return nil, err 50 } 51 52 var res []string 53 return res, extract.IntoSlicePtr(raw.Body, &res, "add_resource_ids") 54 }