github.com/gophercloud/gophercloud@v1.11.0/openstack/sharedfilesystems/v2/schedulerstats/requests.go (about) 1 package schedulerstats 2 3 import ( 4 "github.com/gophercloud/gophercloud" 5 "github.com/gophercloud/gophercloud/pagination" 6 ) 7 8 // ListOptsBuilder allows extensions to add additional parameters to the 9 // List request. 10 type ListOptsBuilder interface { 11 ToPoolsListQuery() (string, error) 12 } 13 14 // ListOpts controls the view of data returned (e.g globally or per project). 15 type ListOpts struct { 16 // The pool name for the back end. 17 ProjectID string `json:"project_id,omitempty"` 18 // The pool name for the back end. 19 PoolName string `json:"pool_name"` 20 // The host name for the back end. 21 HostName string `json:"host_name"` 22 // The name of the back end. 23 BackendName string `json:"backend_name"` 24 // The capabilities for the storage back end. 25 Capabilities string `json:"capabilities"` 26 // The share type name or UUID. Allows filtering back end pools based on the extra-specs in the share type. 27 ShareType string `json:"share_type,omitempty"` 28 } 29 30 // ToPoolsListQuery formats a ListOpts into a query string. 31 func (opts ListOpts) ToPoolsListQuery() (string, error) { 32 q, err := gophercloud.BuildQueryString(opts) 33 return q.String(), err 34 } 35 36 // List makes a request against the API to list pool information. 37 func List(client *gophercloud.ServiceClient, opts ListOptsBuilder) pagination.Pager { 38 url := poolsListURL(client) 39 if opts != nil { 40 query, err := opts.ToPoolsListQuery() 41 if err != nil { 42 return pagination.Pager{Err: err} 43 } 44 url += query 45 } 46 return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { 47 return PoolPage{pagination.SinglePageBase(r)} 48 }) 49 } 50 51 // ListDetailOptsBuilder allows extensions to add additional parameters to the 52 // ListDetail request. 53 type ListDetailOptsBuilder interface { 54 ToPoolsListQuery() (string, error) 55 } 56 57 // ListOpts controls the view of data returned (e.g globally or per project). 58 type ListDetailOpts struct { 59 // The pool name for the back end. 60 ProjectID string `json:"project_id,omitempty"` 61 // The pool name for the back end. 62 PoolName string `json:"pool_name"` 63 // The host name for the back end. 64 HostName string `json:"host_name"` 65 // The name of the back end. 66 BackendName string `json:"backend_name"` 67 // The capabilities for the storage back end. 68 Capabilities string `json:"capabilities"` 69 // The share type name or UUID. Allows filtering back end pools based on the extra-specs in the share type. 70 ShareType string `json:"share_type,omitempty"` 71 } 72 73 // ToPoolsListQuery formats a ListDetailOpts into a query string. 74 func (opts ListDetailOpts) ToPoolsListQuery() (string, error) { 75 q, err := gophercloud.BuildQueryString(opts) 76 return q.String(), err 77 } 78 79 // ListDetail makes a request against the API to list detailed pool information. 80 func ListDetail(client *gophercloud.ServiceClient, opts ListDetailOptsBuilder) pagination.Pager { 81 url := poolsListDetailURL(client) 82 if opts != nil { 83 query, err := opts.ToPoolsListQuery() 84 if err != nil { 85 return pagination.Pager{Err: err} 86 } 87 url += query 88 } 89 return pagination.NewPager(client, url, func(r pagination.PageResult) pagination.Page { 90 return PoolPage{pagination.SinglePageBase(r)} 91 }) 92 }