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