-
Notifications
You must be signed in to change notification settings - Fork 125
/
subscription_metrics_builder.go
390 lines (358 loc) · 11.8 KB
/
subscription_metrics_builder.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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/*
Copyright (c) 2020 Red Hat, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// IMPORTANT: This file has been generated automatically, refrain from modifying it manually as all
// your changes will be lost when the file is generated again.
package v1 // github.com/openshift-online/ocm-sdk-go/accountsmgmt/v1
// SubscriptionMetricsBuilder contains the data and logic needed to build 'subscription_metrics' objects.
//
// Each field is a metric fetched for a specific Subscription's cluster.
type SubscriptionMetricsBuilder struct {
bitmap_ uint32
cloudProvider string
computeNodesCpu *ClusterResourceBuilder
computeNodesMemory *ClusterResourceBuilder
computeNodesSockets *ClusterResourceBuilder
consoleUrl string
cpu *ClusterResourceBuilder
criticalAlertsFiring float64
healthState string
memory *ClusterResourceBuilder
nodes *ClusterMetricsNodesBuilder
openshiftVersion string
operatingSystem string
operatorsConditionFailing float64
region string
sockets *ClusterResourceBuilder
state string
stateDescription string
storage *ClusterResourceBuilder
subscriptionCpuTotal float64
subscriptionObligationExists float64
subscriptionSocketTotal float64
upgrade *ClusterUpgradeBuilder
}
// NewSubscriptionMetrics creates a new builder of 'subscription_metrics' objects.
func NewSubscriptionMetrics() *SubscriptionMetricsBuilder {
return &SubscriptionMetricsBuilder{}
}
// Empty returns true if the builder is empty, i.e. no attribute has a value.
func (b *SubscriptionMetricsBuilder) Empty() bool {
return b == nil || b.bitmap_ == 0
}
// CloudProvider sets the value of the 'cloud_provider' attribute to the given value.
func (b *SubscriptionMetricsBuilder) CloudProvider(value string) *SubscriptionMetricsBuilder {
b.cloudProvider = value
b.bitmap_ |= 1
return b
}
// ComputeNodesCpu sets the value of the 'compute_nodes_cpu' attribute to the given value.
func (b *SubscriptionMetricsBuilder) ComputeNodesCpu(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.computeNodesCpu = value
if value != nil {
b.bitmap_ |= 2
} else {
b.bitmap_ &^= 2
}
return b
}
// ComputeNodesMemory sets the value of the 'compute_nodes_memory' attribute to the given value.
func (b *SubscriptionMetricsBuilder) ComputeNodesMemory(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.computeNodesMemory = value
if value != nil {
b.bitmap_ |= 4
} else {
b.bitmap_ &^= 4
}
return b
}
// ComputeNodesSockets sets the value of the 'compute_nodes_sockets' attribute to the given value.
func (b *SubscriptionMetricsBuilder) ComputeNodesSockets(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.computeNodesSockets = value
if value != nil {
b.bitmap_ |= 8
} else {
b.bitmap_ &^= 8
}
return b
}
// ConsoleUrl sets the value of the 'console_url' attribute to the given value.
func (b *SubscriptionMetricsBuilder) ConsoleUrl(value string) *SubscriptionMetricsBuilder {
b.consoleUrl = value
b.bitmap_ |= 16
return b
}
// Cpu sets the value of the 'cpu' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Cpu(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.cpu = value
if value != nil {
b.bitmap_ |= 32
} else {
b.bitmap_ &^= 32
}
return b
}
// CriticalAlertsFiring sets the value of the 'critical_alerts_firing' attribute to the given value.
func (b *SubscriptionMetricsBuilder) CriticalAlertsFiring(value float64) *SubscriptionMetricsBuilder {
b.criticalAlertsFiring = value
b.bitmap_ |= 64
return b
}
// HealthState sets the value of the 'health_state' attribute to the given value.
func (b *SubscriptionMetricsBuilder) HealthState(value string) *SubscriptionMetricsBuilder {
b.healthState = value
b.bitmap_ |= 128
return b
}
// Memory sets the value of the 'memory' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Memory(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.memory = value
if value != nil {
b.bitmap_ |= 256
} else {
b.bitmap_ &^= 256
}
return b
}
// Nodes sets the value of the 'nodes' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Nodes(value *ClusterMetricsNodesBuilder) *SubscriptionMetricsBuilder {
b.nodes = value
if value != nil {
b.bitmap_ |= 512
} else {
b.bitmap_ &^= 512
}
return b
}
// OpenshiftVersion sets the value of the 'openshift_version' attribute to the given value.
func (b *SubscriptionMetricsBuilder) OpenshiftVersion(value string) *SubscriptionMetricsBuilder {
b.openshiftVersion = value
b.bitmap_ |= 1024
return b
}
// OperatingSystem sets the value of the 'operating_system' attribute to the given value.
func (b *SubscriptionMetricsBuilder) OperatingSystem(value string) *SubscriptionMetricsBuilder {
b.operatingSystem = value
b.bitmap_ |= 2048
return b
}
// OperatorsConditionFailing sets the value of the 'operators_condition_failing' attribute to the given value.
func (b *SubscriptionMetricsBuilder) OperatorsConditionFailing(value float64) *SubscriptionMetricsBuilder {
b.operatorsConditionFailing = value
b.bitmap_ |= 4096
return b
}
// Region sets the value of the 'region' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Region(value string) *SubscriptionMetricsBuilder {
b.region = value
b.bitmap_ |= 8192
return b
}
// Sockets sets the value of the 'sockets' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Sockets(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.sockets = value
if value != nil {
b.bitmap_ |= 16384
} else {
b.bitmap_ &^= 16384
}
return b
}
// State sets the value of the 'state' attribute to the given value.
func (b *SubscriptionMetricsBuilder) State(value string) *SubscriptionMetricsBuilder {
b.state = value
b.bitmap_ |= 32768
return b
}
// StateDescription sets the value of the 'state_description' attribute to the given value.
func (b *SubscriptionMetricsBuilder) StateDescription(value string) *SubscriptionMetricsBuilder {
b.stateDescription = value
b.bitmap_ |= 65536
return b
}
// Storage sets the value of the 'storage' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Storage(value *ClusterResourceBuilder) *SubscriptionMetricsBuilder {
b.storage = value
if value != nil {
b.bitmap_ |= 131072
} else {
b.bitmap_ &^= 131072
}
return b
}
// SubscriptionCpuTotal sets the value of the 'subscription_cpu_total' attribute to the given value.
func (b *SubscriptionMetricsBuilder) SubscriptionCpuTotal(value float64) *SubscriptionMetricsBuilder {
b.subscriptionCpuTotal = value
b.bitmap_ |= 262144
return b
}
// SubscriptionObligationExists sets the value of the 'subscription_obligation_exists' attribute to the given value.
func (b *SubscriptionMetricsBuilder) SubscriptionObligationExists(value float64) *SubscriptionMetricsBuilder {
b.subscriptionObligationExists = value
b.bitmap_ |= 524288
return b
}
// SubscriptionSocketTotal sets the value of the 'subscription_socket_total' attribute to the given value.
func (b *SubscriptionMetricsBuilder) SubscriptionSocketTotal(value float64) *SubscriptionMetricsBuilder {
b.subscriptionSocketTotal = value
b.bitmap_ |= 1048576
return b
}
// Upgrade sets the value of the 'upgrade' attribute to the given value.
func (b *SubscriptionMetricsBuilder) Upgrade(value *ClusterUpgradeBuilder) *SubscriptionMetricsBuilder {
b.upgrade = value
if value != nil {
b.bitmap_ |= 2097152
} else {
b.bitmap_ &^= 2097152
}
return b
}
// Copy copies the attributes of the given object into this builder, discarding any previous values.
func (b *SubscriptionMetricsBuilder) Copy(object *SubscriptionMetrics) *SubscriptionMetricsBuilder {
if object == nil {
return b
}
b.bitmap_ = object.bitmap_
b.cloudProvider = object.cloudProvider
if object.computeNodesCpu != nil {
b.computeNodesCpu = NewClusterResource().Copy(object.computeNodesCpu)
} else {
b.computeNodesCpu = nil
}
if object.computeNodesMemory != nil {
b.computeNodesMemory = NewClusterResource().Copy(object.computeNodesMemory)
} else {
b.computeNodesMemory = nil
}
if object.computeNodesSockets != nil {
b.computeNodesSockets = NewClusterResource().Copy(object.computeNodesSockets)
} else {
b.computeNodesSockets = nil
}
b.consoleUrl = object.consoleUrl
if object.cpu != nil {
b.cpu = NewClusterResource().Copy(object.cpu)
} else {
b.cpu = nil
}
b.criticalAlertsFiring = object.criticalAlertsFiring
b.healthState = object.healthState
if object.memory != nil {
b.memory = NewClusterResource().Copy(object.memory)
} else {
b.memory = nil
}
if object.nodes != nil {
b.nodes = NewClusterMetricsNodes().Copy(object.nodes)
} else {
b.nodes = nil
}
b.openshiftVersion = object.openshiftVersion
b.operatingSystem = object.operatingSystem
b.operatorsConditionFailing = object.operatorsConditionFailing
b.region = object.region
if object.sockets != nil {
b.sockets = NewClusterResource().Copy(object.sockets)
} else {
b.sockets = nil
}
b.state = object.state
b.stateDescription = object.stateDescription
if object.storage != nil {
b.storage = NewClusterResource().Copy(object.storage)
} else {
b.storage = nil
}
b.subscriptionCpuTotal = object.subscriptionCpuTotal
b.subscriptionObligationExists = object.subscriptionObligationExists
b.subscriptionSocketTotal = object.subscriptionSocketTotal
if object.upgrade != nil {
b.upgrade = NewClusterUpgrade().Copy(object.upgrade)
} else {
b.upgrade = nil
}
return b
}
// Build creates a 'subscription_metrics' object using the configuration stored in the builder.
func (b *SubscriptionMetricsBuilder) Build() (object *SubscriptionMetrics, err error) {
object = new(SubscriptionMetrics)
object.bitmap_ = b.bitmap_
object.cloudProvider = b.cloudProvider
if b.computeNodesCpu != nil {
object.computeNodesCpu, err = b.computeNodesCpu.Build()
if err != nil {
return
}
}
if b.computeNodesMemory != nil {
object.computeNodesMemory, err = b.computeNodesMemory.Build()
if err != nil {
return
}
}
if b.computeNodesSockets != nil {
object.computeNodesSockets, err = b.computeNodesSockets.Build()
if err != nil {
return
}
}
object.consoleUrl = b.consoleUrl
if b.cpu != nil {
object.cpu, err = b.cpu.Build()
if err != nil {
return
}
}
object.criticalAlertsFiring = b.criticalAlertsFiring
object.healthState = b.healthState
if b.memory != nil {
object.memory, err = b.memory.Build()
if err != nil {
return
}
}
if b.nodes != nil {
object.nodes, err = b.nodes.Build()
if err != nil {
return
}
}
object.openshiftVersion = b.openshiftVersion
object.operatingSystem = b.operatingSystem
object.operatorsConditionFailing = b.operatorsConditionFailing
object.region = b.region
if b.sockets != nil {
object.sockets, err = b.sockets.Build()
if err != nil {
return
}
}
object.state = b.state
object.stateDescription = b.stateDescription
if b.storage != nil {
object.storage, err = b.storage.Build()
if err != nil {
return
}
}
object.subscriptionCpuTotal = b.subscriptionCpuTotal
object.subscriptionObligationExists = b.subscriptionObligationExists
object.subscriptionSocketTotal = b.subscriptionSocketTotal
if b.upgrade != nil {
object.upgrade, err = b.upgrade.Build()
if err != nil {
return
}
}
return
}