Skip to content

Commit d3d25f8

Browse files
stackit-pipelinemarceljk
authored andcommitted
Generate resourcemanager
1 parent 30db81a commit d3d25f8

21 files changed

+2242
-298
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ed4e4fbee2f5db4d95725108fb3d736e5363fb2f

services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ContainerSearchResult.java

Lines changed: 118 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@
2525
import com.google.gson.stream.JsonWriter;
2626
import java.io.IOException;
2727
import java.util.Arrays;
28+
import java.util.HashMap;
2829
import java.util.HashSet;
30+
import java.util.List;
2931
import java.util.Map;
3032
import java.util.Objects;
31-
import java.util.Set;
3233
import java.util.UUID;
3334

3435
/** ContainerSearchResult */
@@ -239,6 +240,50 @@ public void setOrganizationId(@javax.annotation.Nullable UUID organizationId) {
239240
this.organizationId = organizationId;
240241
}
241242

243+
/**
244+
* A container for additional, undeclared properties. This is a holder for any undeclared
245+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
246+
*/
247+
private Map<String, Object> additionalProperties;
248+
249+
/**
250+
* Set the additional (undeclared) property with the specified name and value. If the property
251+
* does not already exist, create it otherwise replace it.
252+
*
253+
* @param key name of the property
254+
* @param value value of the property
255+
* @return the ContainerSearchResult instance itself
256+
*/
257+
public ContainerSearchResult putAdditionalProperty(String key, Object value) {
258+
if (this.additionalProperties == null) {
259+
this.additionalProperties = new HashMap<String, Object>();
260+
}
261+
this.additionalProperties.put(key, value);
262+
return this;
263+
}
264+
265+
/**
266+
* Return the additional (undeclared) property.
267+
*
268+
* @return a map of objects
269+
*/
270+
public Map<String, Object> getAdditionalProperties() {
271+
return additionalProperties;
272+
}
273+
274+
/**
275+
* Return the additional (undeclared) property with the specified name.
276+
*
277+
* @param key name of the property
278+
* @return an object
279+
*/
280+
public Object getAdditionalProperty(String key) {
281+
if (this.additionalProperties == null) {
282+
return null;
283+
}
284+
return this.additionalProperties.get(key);
285+
}
286+
242287
@Override
243288
public boolean equals(Object o) {
244289
if (this == o) {
@@ -253,12 +298,21 @@ public boolean equals(Object o) {
253298
&& Objects.equals(this.id, containerSearchResult.id)
254299
&& Objects.equals(this.lifecycleState, containerSearchResult.lifecycleState)
255300
&& Objects.equals(this.name, containerSearchResult.name)
256-
&& Objects.equals(this.organizationId, containerSearchResult.organizationId);
301+
&& Objects.equals(this.organizationId, containerSearchResult.organizationId)
302+
&& Objects.equals(
303+
this.additionalProperties, containerSearchResult.additionalProperties);
257304
}
258305

259306
@Override
260307
public int hashCode() {
261-
return Objects.hash(containerId, containerType, id, lifecycleState, name, organizationId);
308+
return Objects.hash(
309+
containerId,
310+
containerType,
311+
id,
312+
lifecycleState,
313+
name,
314+
organizationId,
315+
additionalProperties);
262316
}
263317

264318
@Override
@@ -271,6 +325,9 @@ public String toString() {
271325
sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n");
272326
sb.append(" name: ").append(toIndentedString(name)).append("\n");
273327
sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n");
328+
sb.append(" additionalProperties: ")
329+
.append(toIndentedString(additionalProperties))
330+
.append("\n");
274331
sb.append("}");
275332
return sb.toString();
276333
}
@@ -323,17 +380,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
323380
}
324381
}
325382

326-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
327-
// check to see if the JSON string contains additional fields
328-
for (Map.Entry<String, JsonElement> entry : entries) {
329-
if (!ContainerSearchResult.openapiFields.contains(entry.getKey())) {
330-
throw new IllegalArgumentException(
331-
String.format(
332-
"The field `%s` in the JSON string is not defined in the `ContainerSearchResult` properties. JSON: %s",
333-
entry.getKey(), jsonElement.toString()));
334-
}
335-
}
336-
337383
// check to make sure all required properties/fields are present in the JSON string
338384
for (String requiredField : ContainerSearchResult.openapiRequiredFields) {
339385
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -400,14 +446,71 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
400446
public void write(JsonWriter out, ContainerSearchResult value)
401447
throws IOException {
402448
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
449+
obj.remove("additionalProperties");
450+
// serialize additional properties
451+
if (value.getAdditionalProperties() != null) {
452+
for (Map.Entry<String, Object> entry :
453+
value.getAdditionalProperties().entrySet()) {
454+
if (entry.getValue() instanceof String)
455+
obj.addProperty(entry.getKey(), (String) entry.getValue());
456+
else if (entry.getValue() instanceof Number)
457+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
458+
else if (entry.getValue() instanceof Boolean)
459+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
460+
else if (entry.getValue() instanceof Character)
461+
obj.addProperty(
462+
entry.getKey(), (Character) entry.getValue());
463+
else {
464+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
465+
if (jsonElement.isJsonArray()) {
466+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
467+
} else {
468+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
469+
}
470+
}
471+
}
472+
}
403473
elementAdapter.write(out, obj);
404474
}
405475

406476
@Override
407477
public ContainerSearchResult read(JsonReader in) throws IOException {
408478
JsonElement jsonElement = elementAdapter.read(in);
409479
validateJsonElement(jsonElement);
410-
return thisAdapter.fromJsonTree(jsonElement);
480+
JsonObject jsonObj = jsonElement.getAsJsonObject();
481+
// store additional fields in the deserialized instance
482+
ContainerSearchResult instance = thisAdapter.fromJsonTree(jsonObj);
483+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
484+
if (!openapiFields.contains(entry.getKey())) {
485+
if (entry.getValue().isJsonPrimitive()) { // primitive type
486+
if (entry.getValue().getAsJsonPrimitive().isString())
487+
instance.putAdditionalProperty(
488+
entry.getKey(), entry.getValue().getAsString());
489+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
490+
instance.putAdditionalProperty(
491+
entry.getKey(), entry.getValue().getAsNumber());
492+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
493+
instance.putAdditionalProperty(
494+
entry.getKey(),
495+
entry.getValue().getAsBoolean());
496+
else
497+
throw new IllegalArgumentException(
498+
String.format(
499+
"The field `%s` has unknown primitive type. Value: %s",
500+
entry.getKey(),
501+
entry.getValue().toString()));
502+
} else if (entry.getValue().isJsonArray()) {
503+
instance.putAdditionalProperty(
504+
entry.getKey(),
505+
gson.fromJson(entry.getValue(), List.class));
506+
} else { // JSON object
507+
instance.putAdditionalProperty(
508+
entry.getKey(),
509+
gson.fromJson(entry.getValue(), HashMap.class));
510+
}
511+
}
512+
}
513+
return instance;
411514
}
412515
}.nullSafe();
413516
}

services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateFolderPayload.java

Lines changed: 110 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import java.util.HashMap;
2929
import java.util.HashSet;
3030
import java.util.LinkedHashSet;
31+
import java.util.List;
3132
import java.util.Map;
3233
import java.util.Objects;
3334
import java.util.Set;
@@ -158,6 +159,50 @@ public void setName(@javax.annotation.Nonnull String name) {
158159
this.name = name;
159160
}
160161

162+
/**
163+
* A container for additional, undeclared properties. This is a holder for any undeclared
164+
* properties as specified with the 'additionalProperties' keyword in the OAS document.
165+
*/
166+
private Map<String, Object> additionalProperties;
167+
168+
/**
169+
* Set the additional (undeclared) property with the specified name and value. If the property
170+
* does not already exist, create it otherwise replace it.
171+
*
172+
* @param key name of the property
173+
* @param value value of the property
174+
* @return the CreateFolderPayload instance itself
175+
*/
176+
public CreateFolderPayload putAdditionalProperty(String key, Object value) {
177+
if (this.additionalProperties == null) {
178+
this.additionalProperties = new HashMap<String, Object>();
179+
}
180+
this.additionalProperties.put(key, value);
181+
return this;
182+
}
183+
184+
/**
185+
* Return the additional (undeclared) property.
186+
*
187+
* @return a map of objects
188+
*/
189+
public Map<String, Object> getAdditionalProperties() {
190+
return additionalProperties;
191+
}
192+
193+
/**
194+
* Return the additional (undeclared) property with the specified name.
195+
*
196+
* @param key name of the property
197+
* @return an object
198+
*/
199+
public Object getAdditionalProperty(String key) {
200+
if (this.additionalProperties == null) {
201+
return null;
202+
}
203+
return this.additionalProperties.get(key);
204+
}
205+
161206
@Override
162207
public boolean equals(Object o) {
163208
if (this == o) {
@@ -170,12 +215,14 @@ public boolean equals(Object o) {
170215
return Objects.equals(this.containerParentId, createFolderPayload.containerParentId)
171216
&& Objects.equals(this.labels, createFolderPayload.labels)
172217
&& Objects.equals(this.members, createFolderPayload.members)
173-
&& Objects.equals(this.name, createFolderPayload.name);
218+
&& Objects.equals(this.name, createFolderPayload.name)
219+
&& Objects.equals(
220+
this.additionalProperties, createFolderPayload.additionalProperties);
174221
}
175222

176223
@Override
177224
public int hashCode() {
178-
return Objects.hash(containerParentId, labels, members, name);
225+
return Objects.hash(containerParentId, labels, members, name, additionalProperties);
179226
}
180227

181228
@Override
@@ -188,6 +235,9 @@ public String toString() {
188235
sb.append(" labels: ").append(toIndentedString(labels)).append("\n");
189236
sb.append(" members: ").append(toIndentedString(members)).append("\n");
190237
sb.append(" name: ").append(toIndentedString(name)).append("\n");
238+
sb.append(" additionalProperties: ")
239+
.append(toIndentedString(additionalProperties))
240+
.append("\n");
191241
sb.append("}");
192242
return sb.toString();
193243
}
@@ -233,17 +283,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti
233283
}
234284
}
235285

236-
Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
237-
// check to see if the JSON string contains additional fields
238-
for (Map.Entry<String, JsonElement> entry : entries) {
239-
if (!CreateFolderPayload.openapiFields.contains(entry.getKey())) {
240-
throw new IllegalArgumentException(
241-
String.format(
242-
"The field `%s` in the JSON string is not defined in the `CreateFolderPayload` properties. JSON: %s",
243-
entry.getKey(), jsonElement.toString()));
244-
}
245-
}
246-
247286
// check to make sure all required properties/fields are present in the JSON string
248287
for (String requiredField : CreateFolderPayload.openapiRequiredFields) {
249288
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
@@ -303,14 +342,71 @@ public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
303342
public void write(JsonWriter out, CreateFolderPayload value)
304343
throws IOException {
305344
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
345+
obj.remove("additionalProperties");
346+
// serialize additional properties
347+
if (value.getAdditionalProperties() != null) {
348+
for (Map.Entry<String, Object> entry :
349+
value.getAdditionalProperties().entrySet()) {
350+
if (entry.getValue() instanceof String)
351+
obj.addProperty(entry.getKey(), (String) entry.getValue());
352+
else if (entry.getValue() instanceof Number)
353+
obj.addProperty(entry.getKey(), (Number) entry.getValue());
354+
else if (entry.getValue() instanceof Boolean)
355+
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
356+
else if (entry.getValue() instanceof Character)
357+
obj.addProperty(
358+
entry.getKey(), (Character) entry.getValue());
359+
else {
360+
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
361+
if (jsonElement.isJsonArray()) {
362+
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
363+
} else {
364+
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
365+
}
366+
}
367+
}
368+
}
306369
elementAdapter.write(out, obj);
307370
}
308371

309372
@Override
310373
public CreateFolderPayload read(JsonReader in) throws IOException {
311374
JsonElement jsonElement = elementAdapter.read(in);
312375
validateJsonElement(jsonElement);
313-
return thisAdapter.fromJsonTree(jsonElement);
376+
JsonObject jsonObj = jsonElement.getAsJsonObject();
377+
// store additional fields in the deserialized instance
378+
CreateFolderPayload instance = thisAdapter.fromJsonTree(jsonObj);
379+
for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
380+
if (!openapiFields.contains(entry.getKey())) {
381+
if (entry.getValue().isJsonPrimitive()) { // primitive type
382+
if (entry.getValue().getAsJsonPrimitive().isString())
383+
instance.putAdditionalProperty(
384+
entry.getKey(), entry.getValue().getAsString());
385+
else if (entry.getValue().getAsJsonPrimitive().isNumber())
386+
instance.putAdditionalProperty(
387+
entry.getKey(), entry.getValue().getAsNumber());
388+
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
389+
instance.putAdditionalProperty(
390+
entry.getKey(),
391+
entry.getValue().getAsBoolean());
392+
else
393+
throw new IllegalArgumentException(
394+
String.format(
395+
"The field `%s` has unknown primitive type. Value: %s",
396+
entry.getKey(),
397+
entry.getValue().toString()));
398+
} else if (entry.getValue().isJsonArray()) {
399+
instance.putAdditionalProperty(
400+
entry.getKey(),
401+
gson.fromJson(entry.getValue(), List.class));
402+
} else { // JSON object
403+
instance.putAdditionalProperty(
404+
entry.getKey(),
405+
gson.fromJson(entry.getValue(), HashMap.class));
406+
}
407+
}
408+
}
409+
return instance;
314410
}
315411
}.nullSafe();
316412
}

0 commit comments

Comments
 (0)