forked from cloudfoundry/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
quota.go
120 lines (96 loc) · 2.42 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
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
119
120
package ccv3
import (
"encoding/json"
"code.cloudfoundry.org/cli/types"
)
type Quota struct {
// GUID is the unique ID of the organization quota.
GUID string `json:"guid,omitempty"`
// Name is the name of the organization quota
Name string `json:"name"`
// Apps contain the various limits that are associated with applications
Apps AppLimit `json:"apps"`
// Services contain the various limits that are associated with services
Services ServiceLimit `json:"services"`
// Routes contain the various limits that are associated with routes
Routes RouteLimit `json:"routes"`
}
type AppLimit struct {
TotalMemory *types.NullInt `json:"total_memory_in_mb,omitempty"`
InstanceMemory *types.NullInt `json:"per_process_memory_in_mb,omitempty"`
TotalAppInstances *types.NullInt `json:"total_instances,omitempty"`
}
func (al *AppLimit) UnmarshalJSON(rawJSON []byte) error {
type Alias AppLimit
var aux Alias
err := json.Unmarshal(rawJSON, &aux)
if err != nil {
return err
}
*al = AppLimit(aux)
if al.TotalMemory == nil {
al.TotalMemory = &types.NullInt{
IsSet: false,
Value: 0,
}
}
if al.InstanceMemory == nil {
al.InstanceMemory = &types.NullInt{
IsSet: false,
Value: 0,
}
}
if al.TotalAppInstances == nil {
al.TotalAppInstances = &types.NullInt{
IsSet: false,
Value: 0,
}
}
return nil
}
type ServiceLimit struct {
TotalServiceInstances *types.NullInt `json:"total_service_instances,omitempty"`
PaidServicePlans *bool `json:"paid_services_allowed,omitempty"`
}
func (sl *ServiceLimit) UnmarshalJSON(rawJSON []byte) error {
type Alias ServiceLimit
var aux Alias
err := json.Unmarshal(rawJSON, &aux)
if err != nil {
return err
}
*sl = ServiceLimit(aux)
if sl.TotalServiceInstances == nil {
sl.TotalServiceInstances = &types.NullInt{
IsSet: false,
Value: 0,
}
}
return nil
}
type RouteLimit struct {
TotalRoutes *types.NullInt `json:"total_routes,omitempty"`
TotalReservedPorts *types.NullInt `json:"total_reserved_ports,omitempty"`
}
func (sl *RouteLimit) UnmarshalJSON(rawJSON []byte) error {
type Alias RouteLimit
var aux Alias
err := json.Unmarshal(rawJSON, &aux)
if err != nil {
return err
}
*sl = RouteLimit(aux)
if sl.TotalRoutes == nil {
sl.TotalRoutes = &types.NullInt{
IsSet: false,
Value: 0,
}
}
if sl.TotalReservedPorts == nil {
sl.TotalReservedPorts = &types.NullInt{
IsSet: false,
Value: 0,
}
}
return nil
}