github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/limits/requests.go (about) 1 package limits 2 3 import ( 4 "github.com/huaweicloud/golangsdk" 5 ) 6 7 // GetOptsBuilder allows extensions to add additional parameters to the 8 // Get request. 9 type GetOptsBuilder interface { 10 ToLimitsQuery() (string, error) 11 } 12 13 // GetOpts enables retrieving limits by a specific tenant. 14 type GetOpts struct { 15 // The tenant ID to retrieve limits for. 16 TenantID string `q:"tenant_id"` 17 } 18 19 // ToLimitsQuery formats a GetOpts into a query string. 20 func (opts GetOpts) ToLimitsQuery() (string, error) { 21 q, err := golangsdk.BuildQueryString(opts) 22 return q.String(), err 23 } 24 25 // Get returns the limits about the currently scoped tenant. 26 func Get(client *golangsdk.ServiceClient, opts GetOptsBuilder) (r GetResult) { 27 url := getURL(client) 28 if opts != nil { 29 query, err := opts.ToLimitsQuery() 30 if err != nil { 31 r.Err = err 32 return 33 } 34 url += query 35 } 36 37 _, r.Err = client.Get(url, &r.Body, nil) 38 return 39 }