github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/iec/v1/flavors/requests.go (about) 1 package flavors 2 3 import ( 4 "net/http" 5 6 "github.com/huaweicloud/golangsdk" 7 ) 8 9 //ListOptsBuilder list builder 10 type ListOptsBuilder interface { 11 ToListQuery() (string, error) 12 } 13 14 // ListOpts to list site 15 type ListOpts struct { 16 //SiteIDS query by site ids 17 SiteIDS string `q:"site_ids"` 18 19 //Name query by name 20 Name string `q:"name"` 21 22 //Limit query limit 23 Limit string `q:"limit"` 24 25 //Offset query begin index 26 Offset string `q:"offset"` 27 28 //ID query by id 29 ID string `q:"id"` 30 31 //Area query by area 32 Area string `q:"area"` 33 34 //Province query by province 35 Province string `q:"province"` 36 37 //City query by city 38 City string `q:"city"` 39 40 //Operator query by operator 41 Operator string `q:"operator"` 42 } 43 44 // ToListQuery converts ListOpts structures to query string 45 func (opts ListOpts) ToListQuery() (string, error) { 46 q, err := golangsdk.BuildQueryString(opts) 47 return q.String(), err 48 } 49 50 func List(client *golangsdk.ServiceClient, listOpts ListOptsBuilder) (r GetResult) { 51 url := ListURL(client) 52 if listOpts != nil { 53 query, err := listOpts.ToListQuery() 54 if err != nil { 55 r.Err = err 56 return 57 } 58 url += query 59 } 60 _, r.Err = client.Get(url, &r.Body, &golangsdk.RequestOpts{ 61 OkCodes: []int{http.StatusOK}, 62 }) 63 return 64 }