github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/blockstorage/extensions/schedulerstats/requests.go (about) 1 package schedulerstats 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 "github.com/huaweicloud/golangsdk/pagination" 6 ) 7 8 // ListOptsBuilder allows extensions to add additional parameters to the 9 // List request. 10 type ListOptsBuilder interface { 11 ToStoragePoolsListQuery() (string, error) 12 } 13 14 // ListOpts controls the view of data returned (e.g globally or per project) 15 // via tenant_id and the verbosity via detail. 16 type ListOpts struct { 17 // ID of the tenant to look up storage pools for. 18 TenantID string `q:"tenant_id"` 19 20 // Whether to list extended details. 21 Detail bool `q:"detail"` 22 } 23 24 // ToStoragePoolsListQuery formats a ListOpts into a query string. 25 func (opts ListOpts) ToStoragePoolsListQuery() (string, error) { 26 q, err := golangsdk.BuildQueryString(opts) 27 return q.String(), err 28 } 29 30 // List makes a request against the API to list storage pool information. 31 func List(client *golangsdk.ServiceClient, opts ListOptsBuilder) pagination.Pager { 32 url := storagePoolsListURL(client) 33 if opts != nil { 34 query, err := opts.ToStoragePoolsListQuery() 35 if err != nil { 36 return pagination.Pager{Err: err} 37 } 38 url += query 39 } 40 return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { 41 return StoragePoolPage{pagination.SinglePageBase(r)} 42 }) 43 }