cisco/sdk/quota.go -rw-r--r-- 2.0 KiB View raw
                                                                                
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
package cisco

import (
	"encoding/json"
)

type Quota struct {
	Role      string `json:"role"`
	Instances int    `json:"instances"`
	Ipv4      int    `json:"ipv4"`
	Storage   int    `json:"storage"`
	Invites   int    `json:"invites"`
}

func GetQuota(name string) (Quota, error) {
	var result Quota

	data, err := SendRequest(AdminQuotaGetRoute, Request{
		Arg: name,
	})

	if err != nil {
		return result, err
	}

	err = json.Unmarshal(data.([]byte), &result)
	return result, err
}

func ListQuota() ([]Quota, error) {
	var result []Quota

	data, err := SendRequest(AdminQuotaListRoute, Request{})

	if err != nil {
		return nil, err
	}

	err = json.Unmarshal(data.([]byte), &result)
	return result, err
}

func CreateQuota(name string) error {
	_, err := SendRequest(AdminQuotaCreateRoute, Request{
		Arg: name,
	})

	return err
}

func DeleteQuota(name string) error {
	_, err := SendRequest(AdminQuotaDeleteRoute, Request{
		Arg: name,
	})

	return err
}

type QuotaInstanceUpdate struct {
	Instance int `json:"instance"`
}

func UpdateInstanceQuota(name string, instance int) error {
	_, err := SendRequest(AdminQuotaUpdateInstanceRoute, Request{
		Arg: name,
		Data: &QuotaInstanceUpdate{
			Instance: instance,
		},
	})

	return err
}

type QuotaIpv4Update struct {
	Ipv4 int `json:"ipv4"`
}

func UpdateIpv4Quota(name string, ipv4 int) error {
	_, err := SendRequest(AdminQuotaUpdateIpv4Route, Request{
		Arg: name,
		Data: &QuotaIpv4Update{
			Ipv4: ipv4,
		},
	})

	return err
}

type QuotaStorageUpdate struct {
	Storage int `json:"storage"`
}

func UpdateStorageQuota(name string, storage int) error {
	_, err := SendRequest(AdminQuotaUpdateStorageRoute, Request{
		Arg: name,
		Data: &QuotaStorageUpdate{
			Storage: storage,
		},
	})

	return err
}

type QuotaInvitesUpdate struct {
	Invites int `json:"invites"`
}

func UpdateInvitesQuota(name string, invites int) error {
	_, err := SendRequest(AdminQuotaUpdateInvitesRoute, Request{
		Arg: name,
		Data: &QuotaInvitesUpdate{
			Invites: invites,
		},
	})

	return err
}