forked from civo/civogo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquota.go
52 lines (47 loc) · 2.09 KB
/
quota.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
40
41
42
43
44
45
46
47
48
49
50
51
52
package civogo
import (
"bytes"
"encoding/json"
)
// Quota represents the available limits and usage for an account's Civo quota
type Quota struct {
ID string `json:"id"`
DefaultUserID string `json:"default_user_id"`
DefaultUserEmailAddress string `json:"default_user_email_address"`
InstanceCountLimit int `json:"instance_count_limit"`
InstanceCountUsage int `json:"instance_count_usage"`
CPUCoreLimit int `json:"cpu_core_limit"`
CPUCoreUsage int `json:"cpu_core_usage"`
RAMMegabytesLimit int `json:"ram_mb_limit"`
RAMMegabytesUsage int `json:"ram_mb_usage"`
DiskGigabytesLimit int `json:"disk_gb_limit"`
DiskGigabytesUsage int `json:"disk_gb_usage"`
DiskVolumeCountLimit int `json:"disk_volume_count_limit"`
DiskVolumeCountUsage int `json:"disk_volume_count_usage"`
DiskSnapshotCountLimit int `json:"disk_snapshot_count_limit"`
DiskSnapshotCountUsage int `json:"disk_snapshot_count_usage"`
PublicIPAddressLimit int `json:"public_ip_address_limit"`
PublicIPAddressUsage int `json:"public_ip_address_usage"`
SubnetCountLimit int `json:"subnet_count_limit"`
SubnetCountUsage int `json:"subnet_count_usage"`
NetworkCountLimit int `json:"network_count_limit"`
NetworkCountUsage int `json:"network_count_usage"`
SecurityGroupLimit int `json:"security_group_limit"`
SecurityGroupUsage int `json:"security_group_usage"`
SecurityGroupRuleLimit int `json:"security_group_rule_limit"`
SecurityGroupRuleUsage int `json:"security_group_rule_usage"`
PortCountLimit int `json:"port_count_limit"`
PortCountUsage int `json:"port_count_usage"`
}
// GetQuota returns all load balancers owned by the calling API account
func (c *Client) GetQuota() (*Quota, error) {
resp, err := c.SendGetRequest("/v2/quota")
if err != nil {
return nil, decodeERROR(err)
}
var quota Quota
if err := json.NewDecoder(bytes.NewReader(resp)).Decode("a); err != nil {
return nil, err
}
return "a, nil
}