-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCreateLoadBalancerPayload.java
More file actions
939 lines (830 loc) · 32 KB
/
Copy pathCreateLoadBalancerPayload.java
File metadata and controls
939 lines (830 loc) · 32 KB
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
/*
* STACKIT Application Load Balancer API
* This API offers an interface to provision and manage Application Load Balancers in your STACKIT project.This solution offers modern L7 load balancing. Current features include TLS, path and prefix based routing aswell as routing based on headers, query parameters and keeping connections persistent with cookies and web sockets. For each Application Load Balancer provided, two VMs are deployed in your STACKIT project and are subject to fees.
*
* The version of the OpenAPI document: 2.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package cloud.stackit.sdk.alb.v2api.model;
import cloud.stackit.sdk.alb.v2api.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/** CreateLoadBalancerPayload */
@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0")
public class CreateLoadBalancerPayload {
public static final String SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT =
"disableTargetSecurityGroupAssignment";
@SerializedName(SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT)
@javax.annotation.Nullable private Boolean disableTargetSecurityGroupAssignment;
public static final String SERIALIZED_NAME_ERRORS = "errors";
@SerializedName(SERIALIZED_NAME_ERRORS)
@javax.annotation.Nullable private List<LoadBalancerError> errors = new ArrayList<>();
public static final String SERIALIZED_NAME_EXTERNAL_ADDRESS = "externalAddress";
@SerializedName(SERIALIZED_NAME_EXTERNAL_ADDRESS)
@javax.annotation.Nullable private String externalAddress;
public static final String SERIALIZED_NAME_LABELS = "labels";
@SerializedName(SERIALIZED_NAME_LABELS)
@javax.annotation.Nullable private Map<String, String> labels = new HashMap<>();
public static final String SERIALIZED_NAME_LISTENERS = "listeners";
@SerializedName(SERIALIZED_NAME_LISTENERS)
@javax.annotation.Nullable private List<Listener> listeners = new ArrayList<>();
public static final String SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP =
"loadBalancerSecurityGroup";
@SerializedName(SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP)
@javax.annotation.Nullable private SecurityGroup loadBalancerSecurityGroup;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
@javax.annotation.Nullable private String name;
public static final String SERIALIZED_NAME_NETWORKS = "networks";
@SerializedName(SERIALIZED_NAME_NETWORKS)
@javax.annotation.Nullable private List<Network> networks = new ArrayList<>();
public static final String SERIALIZED_NAME_OPTIONS = "options";
@SerializedName(SERIALIZED_NAME_OPTIONS)
@javax.annotation.Nullable private LoadBalancerOptions options;
public static final String SERIALIZED_NAME_PLAN_ID = "planId";
@SerializedName(SERIALIZED_NAME_PLAN_ID)
@javax.annotation.Nullable private String planId;
public static final String SERIALIZED_NAME_PRIVATE_ADDRESS = "privateAddress";
@SerializedName(SERIALIZED_NAME_PRIVATE_ADDRESS)
@javax.annotation.Nullable private String privateAddress;
public static final String SERIALIZED_NAME_REGION = "region";
@SerializedName(SERIALIZED_NAME_REGION)
@javax.annotation.Nullable private String region;
/** Gets or Sets status */
@JsonAdapter(StatusEnum.Adapter.class)
public enum StatusEnum {
STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"),
STATUS_PENDING("STATUS_PENDING"),
STATUS_READY("STATUS_READY"),
STATUS_ERROR("STATUS_ERROR"),
STATUS_TERMINATING("STATUS_TERMINATING"),
UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");
private String value;
StatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
return UNKNOWN_DEFAULT_OPEN_API;
}
public static class Adapter extends TypeAdapter<StatusEnum> {
@Override
public void write(final JsonWriter jsonWriter, final StatusEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public StatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return StatusEnum.fromValue(value);
}
}
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
String value = jsonElement.getAsString();
StatusEnum.fromValue(value);
}
}
public static final String SERIALIZED_NAME_STATUS = "status";
@SerializedName(SERIALIZED_NAME_STATUS)
@javax.annotation.Nullable private StatusEnum status;
public static final String SERIALIZED_NAME_TARGET_POOLS = "targetPools";
@SerializedName(SERIALIZED_NAME_TARGET_POOLS)
@javax.annotation.Nullable private List<TargetPool> targetPools = new ArrayList<>();
public static final String SERIALIZED_NAME_TARGET_SECURITY_GROUP = "targetSecurityGroup";
@SerializedName(SERIALIZED_NAME_TARGET_SECURITY_GROUP)
@javax.annotation.Nullable private SecurityGroup targetSecurityGroup;
public static final String SERIALIZED_NAME_VERSION = "version";
@SerializedName(SERIALIZED_NAME_VERSION)
@javax.annotation.Nullable private String version;
public CreateLoadBalancerPayload() {}
public CreateLoadBalancerPayload(
List<LoadBalancerError> errors,
SecurityGroup loadBalancerSecurityGroup,
String privateAddress,
String region,
StatusEnum status,
SecurityGroup targetSecurityGroup,
String version) {
this();
this.errors = errors;
this.loadBalancerSecurityGroup = loadBalancerSecurityGroup;
this.privateAddress = privateAddress;
this.region = region;
this.status = status;
this.targetSecurityGroup = targetSecurityGroup;
this.version = version;
}
public CreateLoadBalancerPayload disableTargetSecurityGroupAssignment(
@javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) {
this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment;
return this;
}
/**
* Disable target security group assignemt to allow targets outside of the given network.
* Connectivity to targets need to be ensured by the customer, including routing and Security
* Groups (targetSecurityGroup can be assigned). Not changeable after creation.
*
* @return disableTargetSecurityGroupAssignment
*/
@javax.annotation.Nullable public Boolean getDisableTargetSecurityGroupAssignment() {
return disableTargetSecurityGroupAssignment;
}
public void setDisableTargetSecurityGroupAssignment(
@javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) {
this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment;
}
/**
* Reports all errors a Application Load Balancer has.
*
* @return errors
*/
@javax.annotation.Nullable public List<LoadBalancerError> getErrors() {
return errors;
}
public CreateLoadBalancerPayload externalAddress(
@javax.annotation.Nullable String externalAddress) {
this.externalAddress = externalAddress;
return this;
}
/**
* The external IP address where this Application Load Balancer is exposed. Not changeable after
* creation.
*
* @return externalAddress
*/
@javax.annotation.Nullable public String getExternalAddress() {
return externalAddress;
}
public void setExternalAddress(@javax.annotation.Nullable String externalAddress) {
this.externalAddress = externalAddress;
}
public CreateLoadBalancerPayload labels(@javax.annotation.Nullable Map<String, String> labels) {
this.labels = labels;
return this;
}
public CreateLoadBalancerPayload putLabelsItem(String key, String labelsItem) {
if (this.labels == null) {
this.labels = new HashMap<>();
}
this.labels.put(key, labelsItem);
return this;
}
/**
* Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64
* per ALB. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end
* with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in
* between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage
* them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed).
* Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes
* (-), underscores (_), dots (.), and alphanumerics in between.
*
* @return labels
*/
@javax.annotation.Nullable public Map<String, String> getLabels() {
return labels;
}
public void setLabels(@javax.annotation.Nullable Map<String, String> labels) {
this.labels = labels;
}
public CreateLoadBalancerPayload listeners(
@javax.annotation.Nullable List<Listener> listeners) {
this.listeners = listeners;
return this;
}
public CreateLoadBalancerPayload addListenersItem(Listener listenersItem) {
if (this.listeners == null) {
this.listeners = new ArrayList<>();
}
this.listeners.add(listenersItem);
return this;
}
/**
* There is a maximum listener count of 20.
*
* @return listeners
*/
@javax.annotation.Nullable public List<Listener> getListeners() {
return listeners;
}
public void setListeners(@javax.annotation.Nullable List<Listener> listeners) {
this.listeners = listeners;
}
/**
* Security Group permitting network traffic from the LoadBalancer to the targets. Useful when
* disableTargetSecurityGroupAssignment=true to manually assign target security groups to
* targets.
*
* @return loadBalancerSecurityGroup
*/
@javax.annotation.Nullable public SecurityGroup getLoadBalancerSecurityGroup() {
return loadBalancerSecurityGroup;
}
public CreateLoadBalancerPayload name(@javax.annotation.Nullable String name) {
this.name = name;
return this;
}
/**
* Application Load Balancer name. Not changeable after creation.
*
* @return name
*/
@javax.annotation.Nullable public String getName() {
return name;
}
public void setName(@javax.annotation.Nullable String name) {
this.name = name;
}
public CreateLoadBalancerPayload networks(@javax.annotation.Nullable List<Network> networks) {
this.networks = networks;
return this;
}
public CreateLoadBalancerPayload addNetworksItem(Network networksItem) {
if (this.networks == null) {
this.networks = new ArrayList<>();
}
this.networks.add(networksItem);
return this;
}
/**
* List of networks that listeners and targets reside in. Currently limited to one. Not
* changeable after creation.
*
* @return networks
*/
@javax.annotation.Nullable public List<Network> getNetworks() {
return networks;
}
public void setNetworks(@javax.annotation.Nullable List<Network> networks) {
this.networks = networks;
}
public CreateLoadBalancerPayload options(
@javax.annotation.Nullable LoadBalancerOptions options) {
this.options = options;
return this;
}
/**
* Get options
*
* @return options
*/
@javax.annotation.Nullable public LoadBalancerOptions getOptions() {
return options;
}
public void setOptions(@javax.annotation.Nullable LoadBalancerOptions options) {
this.options = options;
}
public CreateLoadBalancerPayload planId(@javax.annotation.Nullable String planId) {
this.planId = planId;
return this;
}
/**
* Service Plan configures the size of the Application Load Balancer. Currently supported plan
* is p10. This list can change in the future where plan ids will be removed and new plans by
* added. That is the reason this is not an enum.
*
* @return planId
*/
@javax.annotation.Nullable public String getPlanId() {
return planId;
}
public void setPlanId(@javax.annotation.Nullable String planId) {
this.planId = planId;
}
/**
* Transient private Application Load Balancer IP address that can change any time.
*
* @return privateAddress
*/
@javax.annotation.Nullable public String getPrivateAddress() {
return privateAddress;
}
/**
* Region of the LoadBalancer.
*
* @return region
*/
@javax.annotation.Nullable public String getRegion() {
return region;
}
/**
* Get status
*
* @return status
*/
@javax.annotation.Nullable public StatusEnum getStatus() {
return status;
}
public CreateLoadBalancerPayload targetPools(
@javax.annotation.Nullable List<TargetPool> targetPools) {
this.targetPools = targetPools;
return this;
}
public CreateLoadBalancerPayload addTargetPoolsItem(TargetPool targetPoolsItem) {
if (this.targetPools == null) {
this.targetPools = new ArrayList<>();
}
this.targetPools.add(targetPoolsItem);
return this;
}
/**
* List of all target pools which will be used in the Application Load Balancer. Limited to 20.
*
* @return targetPools
*/
@javax.annotation.Nullable public List<TargetPool> getTargetPools() {
return targetPools;
}
public void setTargetPools(@javax.annotation.Nullable List<TargetPool> targetPools) {
this.targetPools = targetPools;
}
/**
* Security Group that allows the targets to receive traffic from the LoadBalancer. Useful when
* disableTargetSecurityGroupAssignment=true to manually assign target security groups to
* targets.
*
* @return targetSecurityGroup
*/
@javax.annotation.Nullable public SecurityGroup getTargetSecurityGroup() {
return targetSecurityGroup;
}
/**
* Application Load Balancer resource version. Must be empty or unset for creating Application
* Load Balancers, non-empty for updating. Semantics: While retrieving, this is the current
* version of this Application Load Balancer resource that changes during updates. On updates
* this field specified the Application Load Balancer version you calculated your update for
* instead of the future version to enable concurrency safe updates. Update calls will then
* report the new version in their result as you would see with a Application Load Balancer
* retrieval call later. There exist no total order of the version, so you can only compare it
* for equality, but not for less/greater than another version. Since the creation of
* Application Load Balancer is always intended to create the first version of it, there should
* be no existing version. That's why this field must by empty of not present in that case.
*
* @return version
*/
@javax.annotation.Nullable public String getVersion() {
return version;
}
/**
* A container for additional, undeclared properties. This is a holder for any undeclared
* properties as specified with the 'additionalProperties' keyword in the OAS document.
*/
private Map<String, Object> additionalProperties;
/**
* Set the additional (undeclared) property with the specified name and value. If the property
* does not already exist, create it otherwise replace it.
*
* @param key name of the property
* @param value value of the property
* @return the CreateLoadBalancerPayload instance itself
*/
public CreateLoadBalancerPayload putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap<String, Object>();
}
this.additionalProperties.put(key, value);
return this;
}
/**
* Return the additional (undeclared) property.
*
* @return a map of objects
*/
public Map<String, Object> getAdditionalProperties() {
return additionalProperties;
}
/**
* Return the additional (undeclared) property with the specified name.
*
* @param key name of the property
* @return an object
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CreateLoadBalancerPayload createLoadBalancerPayload = (CreateLoadBalancerPayload) o;
return Objects.equals(
this.disableTargetSecurityGroupAssignment,
createLoadBalancerPayload.disableTargetSecurityGroupAssignment)
&& Objects.equals(this.errors, createLoadBalancerPayload.errors)
&& Objects.equals(this.externalAddress, createLoadBalancerPayload.externalAddress)
&& Objects.equals(this.labels, createLoadBalancerPayload.labels)
&& Objects.equals(this.listeners, createLoadBalancerPayload.listeners)
&& Objects.equals(
this.loadBalancerSecurityGroup,
createLoadBalancerPayload.loadBalancerSecurityGroup)
&& Objects.equals(this.name, createLoadBalancerPayload.name)
&& Objects.equals(this.networks, createLoadBalancerPayload.networks)
&& Objects.equals(this.options, createLoadBalancerPayload.options)
&& Objects.equals(this.planId, createLoadBalancerPayload.planId)
&& Objects.equals(this.privateAddress, createLoadBalancerPayload.privateAddress)
&& Objects.equals(this.region, createLoadBalancerPayload.region)
&& Objects.equals(this.status, createLoadBalancerPayload.status)
&& Objects.equals(this.targetPools, createLoadBalancerPayload.targetPools)
&& Objects.equals(
this.targetSecurityGroup, createLoadBalancerPayload.targetSecurityGroup)
&& Objects.equals(this.version, createLoadBalancerPayload.version)
&& Objects.equals(
this.additionalProperties, createLoadBalancerPayload.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(
disableTargetSecurityGroupAssignment,
errors,
externalAddress,
labels,
listeners,
loadBalancerSecurityGroup,
name,
networks,
options,
planId,
privateAddress,
region,
status,
targetPools,
targetSecurityGroup,
version,
additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CreateLoadBalancerPayload {\n");
sb.append(" disableTargetSecurityGroupAssignment: ")
.append(toIndentedString(disableTargetSecurityGroupAssignment))
.append("\n");
sb.append(" errors: ").append(toIndentedString(errors)).append("\n");
sb.append(" externalAddress: ").append(toIndentedString(externalAddress)).append("\n");
sb.append(" labels: ").append(toIndentedString(labels)).append("\n");
sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n");
sb.append(" loadBalancerSecurityGroup: ")
.append(toIndentedString(loadBalancerSecurityGroup))
.append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" networks: ").append(toIndentedString(networks)).append("\n");
sb.append(" options: ").append(toIndentedString(options)).append("\n");
sb.append(" planId: ").append(toIndentedString(planId)).append("\n");
sb.append(" privateAddress: ").append(toIndentedString(privateAddress)).append("\n");
sb.append(" region: ").append(toIndentedString(region)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" targetPools: ").append(toIndentedString(targetPools)).append("\n");
sb.append(" targetSecurityGroup: ")
.append(toIndentedString(targetSecurityGroup))
.append("\n");
sb.append(" version: ").append(toIndentedString(version)).append("\n");
sb.append(" additionalProperties: ")
.append(toIndentedString(additionalProperties))
.append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet<String> openapiFields;
public static HashSet<String> openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields =
new HashSet<String>(
Arrays.asList(
"disableTargetSecurityGroupAssignment",
"errors",
"externalAddress",
"labels",
"listeners",
"loadBalancerSecurityGroup",
"name",
"networks",
"options",
"planId",
"privateAddress",
"region",
"status",
"targetPools",
"targetSecurityGroup",
"version"));
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>(0);
}
/**
* Validates the JSON Element and throws an exception if issues found
*
* @param jsonElement JSON Element
* @throws IOException if the JSON Element is invalid with respect to CreateLoadBalancerPayload
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!CreateLoadBalancerPayload.openapiRequiredFields
.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The required field(s) %s in CreateLoadBalancerPayload is not found in the empty JSON string",
CreateLoadBalancerPayload.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) {
JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors");
if (jsonArrayerrors != null) {
// ensure the json data is an array
if (!jsonObj.get("errors").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `errors` to be an array in the JSON string but got `%s`",
jsonObj.get("errors").toString()));
}
// validate the optional field `errors` (array)
for (int i = 0; i < jsonArrayerrors.size(); i++) {
LoadBalancerError.validateJsonElement(jsonArrayerrors.get(i));
}
;
}
}
if ((jsonObj.get("externalAddress") != null && !jsonObj.get("externalAddress").isJsonNull())
&& !jsonObj.get("externalAddress").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `externalAddress` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("externalAddress").toString()));
}
if (jsonObj.get("listeners") != null && !jsonObj.get("listeners").isJsonNull()) {
JsonArray jsonArraylisteners = jsonObj.getAsJsonArray("listeners");
if (jsonArraylisteners != null) {
// ensure the json data is an array
if (!jsonObj.get("listeners").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `listeners` to be an array in the JSON string but got `%s`",
jsonObj.get("listeners").toString()));
}
// validate the optional field `listeners` (array)
for (int i = 0; i < jsonArraylisteners.size(); i++) {
Listener.validateJsonElement(jsonArraylisteners.get(i));
}
;
}
}
// validate the optional field `loadBalancerSecurityGroup`
if (jsonObj.get("loadBalancerSecurityGroup") != null
&& !jsonObj.get("loadBalancerSecurityGroup").isJsonNull()) {
SecurityGroup.validateJsonElement(jsonObj.get("loadBalancerSecurityGroup"));
}
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull())
&& !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `name` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("name").toString()));
}
if (jsonObj.get("networks") != null && !jsonObj.get("networks").isJsonNull()) {
JsonArray jsonArraynetworks = jsonObj.getAsJsonArray("networks");
if (jsonArraynetworks != null) {
// ensure the json data is an array
if (!jsonObj.get("networks").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `networks` to be an array in the JSON string but got `%s`",
jsonObj.get("networks").toString()));
}
// validate the optional field `networks` (array)
for (int i = 0; i < jsonArraynetworks.size(); i++) {
Network.validateJsonElement(jsonArraynetworks.get(i));
}
;
}
}
// validate the optional field `options`
if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) {
LoadBalancerOptions.validateJsonElement(jsonObj.get("options"));
}
if ((jsonObj.get("planId") != null && !jsonObj.get("planId").isJsonNull())
&& !jsonObj.get("planId").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `planId` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("planId").toString()));
}
if ((jsonObj.get("privateAddress") != null && !jsonObj.get("privateAddress").isJsonNull())
&& !jsonObj.get("privateAddress").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `privateAddress` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("privateAddress").toString()));
}
if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull())
&& !jsonObj.get("region").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `region` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("region").toString()));
}
if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull())
&& !jsonObj.get("status").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `status` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("status").toString()));
}
// validate the optional field `status`
if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
StatusEnum.validateJsonElement(jsonObj.get("status"));
}
if (jsonObj.get("targetPools") != null && !jsonObj.get("targetPools").isJsonNull()) {
JsonArray jsonArraytargetPools = jsonObj.getAsJsonArray("targetPools");
if (jsonArraytargetPools != null) {
// ensure the json data is an array
if (!jsonObj.get("targetPools").isJsonArray()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `targetPools` to be an array in the JSON string but got `%s`",
jsonObj.get("targetPools").toString()));
}
// validate the optional field `targetPools` (array)
for (int i = 0; i < jsonArraytargetPools.size(); i++) {
TargetPool.validateJsonElement(jsonArraytargetPools.get(i));
}
;
}
}
// validate the optional field `targetSecurityGroup`
if (jsonObj.get("targetSecurityGroup") != null
&& !jsonObj.get("targetSecurityGroup").isJsonNull()) {
SecurityGroup.validateJsonElement(jsonObj.get("targetSecurityGroup"));
}
if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull())
&& !jsonObj.get("version").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"Expected the field `version` to be a primitive type in the JSON string but got `%s`",
jsonObj.get("version").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!CreateLoadBalancerPayload.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CreateLoadBalancerPayload' and its
// subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<CreateLoadBalancerPayload> thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CreateLoadBalancerPayload.class));
return (TypeAdapter<T>)
new TypeAdapter<CreateLoadBalancerPayload>() {
@Override
public void write(JsonWriter out, CreateLoadBalancerPayload value)
throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// serialize additional properties
if (value.getAdditionalProperties() != null) {
for (Map.Entry<String, Object> entry :
value.getAdditionalProperties().entrySet()) {
if (entry.getValue() instanceof String)
obj.addProperty(entry.getKey(), (String) entry.getValue());
else if (entry.getValue() instanceof Number)
obj.addProperty(entry.getKey(), (Number) entry.getValue());
else if (entry.getValue() instanceof Boolean)
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
else if (entry.getValue() instanceof Character)
obj.addProperty(
entry.getKey(), (Character) entry.getValue());
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
}
}
}
}
elementAdapter.write(out, obj);
}
@Override
public CreateLoadBalancerPayload read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
CreateLoadBalancerPayload instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
if (!openapiFields.contains(entry.getKey())) {
if (entry.getValue().isJsonPrimitive()) { // primitive type
if (entry.getValue().getAsJsonPrimitive().isString())
instance.putAdditionalProperty(
entry.getKey(), entry.getValue().getAsString());
else if (entry.getValue().getAsJsonPrimitive().isNumber())
instance.putAdditionalProperty(
entry.getKey(), entry.getValue().getAsNumber());
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
instance.putAdditionalProperty(
entry.getKey(),
entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(
String.format(
java.util.Locale.ROOT,
"The field `%s` has unknown primitive type. Value: %s",
entry.getKey(),
entry.getValue().toString()));
} else if (entry.getValue().isJsonArray()) {
instance.putAdditionalProperty(
entry.getKey(),
gson.fromJson(entry.getValue(), List.class));
} else { // JSON object
instance.putAdditionalProperty(
entry.getKey(),
gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
return instance;
}
}.nullSafe();
}
}
/**
* Create an instance of CreateLoadBalancerPayload given an JSON string
*
* @param jsonString JSON string
* @return An instance of CreateLoadBalancerPayload
* @throws IOException if the JSON string is invalid with respect to CreateLoadBalancerPayload
*/
public static CreateLoadBalancerPayload fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CreateLoadBalancerPayload.class);
}
/**
* Convert an instance of CreateLoadBalancerPayload to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}