blob: 70324b8356a07ae6f7ad33b738f18f2d52df05c9 [file] [log] [blame]
Joe Topjiana08c1d22016-11-04 10:33:00 -06001package limits
2
3import (
4 "github.com/gophercloud/gophercloud"
5)
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}