github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/evs/v1/volumes/list.go (about) 1 package volumes 2 3 import ( 4 "github.com/opentelekomcloud/gophertelekomcloud" 5 "github.com/opentelekomcloud/gophertelekomcloud/internal/extract" 6 ) 7 8 type ListOpts struct { 9 // admin-only option. Set it to true to see all tenant volumes. 10 AllTenants bool `q:"all_tenants"` 11 // List only volumes that contain Metadata. 12 Metadata map[string]string `q:"metadata"` 13 // List only volumes that have Name as the display name. 14 Name string `q:"display_name"` 15 // List only volumes that have a status of Status. 16 Status string `q:"status"` 17 } 18 19 func List(client *golangsdk.ServiceClient, opts ListOpts) ([]Volume, error) { 20 url, err := golangsdk.NewURLBuilder().WithEndpoints("volumes").WithQueryParams(&opts).Build() 21 if err != nil { 22 return nil, err 23 } 24 25 raw, err := client.Get(client.ServiceURL(url.String()), nil, nil) 26 if err != nil { 27 return nil, err 28 } 29 30 var res []Volume 31 err = extract.IntoSlicePtr(raw.Body, &res, "volumes") 32 return res, err 33 }