blob: 3b3c95bcd3b2aa9d4cc7bd90afca014b96e9c02d [file] [log] [blame]
Joe Topjiana08c1d22016-11-04 10:33:00 -06001package limits
2
3import (
Krzysztof Szukiełojć3f41d082017-05-07 14:43:06 +02004 "gerrit.mcp.mirantis.net/debian/gophercloud.git"
Joe Topjiana08c1d22016-11-04 10:33:00 -06005)
6
7// GetOptsBuilder allows extensions to add additional parameters to the
8// Get request.
9type GetOptsBuilder interface {
10 ToLimitsQuery() (string, error)
11}
12
13// GetOpts enables retrieving limits by a specific tenant.
14type 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.
20func (opts GetOpts) ToLimitsQuery() (string, error) {
21 q, err := gophercloud.BuildQueryString(opts)
22 return q.String(), err
23}
24
25// Get returns the limits about the currently scoped tenant.
26func Get(client *gophercloud.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}