diff --git a/services/serverupdate/oas_commit b/services/serverupdate/oas_commit new file mode 100644 index 0000000..148a7d9 --- /dev/null +++ b/services/serverupdate/oas_commit @@ -0,0 +1 @@ +ed4e4fbee2f5db4d95725108fb3d736e5363fb2f diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdatePayload.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdatePayload.java index 7d495eb..4f604fd 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdatePayload.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdatePayload.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** CreateUpdatePayload */ @javax.annotation.Generated( @@ -86,6 +87,50 @@ public void setMaintenanceWindow(@javax.annotation.Nonnull Integer maintenanceWi this.maintenanceWindow = maintenanceWindow; } + /** + * 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 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 CreateUpdatePayload instance itself + */ + public CreateUpdatePayload putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -96,12 +141,14 @@ public boolean equals(Object o) { } CreateUpdatePayload createUpdatePayload = (CreateUpdatePayload) o; return Objects.equals(this.backupBeforeUpdate, createUpdatePayload.backupBeforeUpdate) - && Objects.equals(this.maintenanceWindow, createUpdatePayload.maintenanceWindow); + && Objects.equals(this.maintenanceWindow, createUpdatePayload.maintenanceWindow) + && Objects.equals( + this.additionalProperties, createUpdatePayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(backupBeforeUpdate, maintenanceWindow); + return Objects.hash(backupBeforeUpdate, maintenanceWindow, additionalProperties); } @Override @@ -114,6 +161,9 @@ public String toString() { sb.append(" maintenanceWindow: ") .append(toIndentedString(maintenanceWindow)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -158,17 +208,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateUpdatePayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CreateUpdatePayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateUpdatePayload.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -198,6 +237,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CreateUpdatePayload value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -205,7 +268,40 @@ public void write(JsonWriter out, CreateUpdatePayload value) public CreateUpdatePayload read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateUpdatePayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdateSchedulePayload.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdateSchedulePayload.java index 7624ad7..aea6808 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdateSchedulePayload.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/CreateUpdateSchedulePayload.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** CreateUpdateSchedulePayload */ @javax.annotation.Generated( @@ -137,6 +138,50 @@ public void setRrule(@javax.annotation.Nonnull String rrule) { this.rrule = rrule; } + /** + * 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 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 CreateUpdateSchedulePayload instance itself + */ + public CreateUpdateSchedulePayload putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -150,12 +195,15 @@ public boolean equals(Object o) { && Objects.equals( this.maintenanceWindow, createUpdateSchedulePayload.maintenanceWindow) && Objects.equals(this.name, createUpdateSchedulePayload.name) - && Objects.equals(this.rrule, createUpdateSchedulePayload.rrule); + && Objects.equals(this.rrule, createUpdateSchedulePayload.rrule) + && Objects.equals( + this.additionalProperties, + createUpdateSchedulePayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, maintenanceWindow, name, rrule); + return Objects.hash(enabled, maintenanceWindow, name, rrule, additionalProperties); } @Override @@ -168,6 +216,9 @@ public String toString() { .append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -214,17 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateUpdateSchedulePayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CreateUpdateSchedulePayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : CreateUpdateSchedulePayload.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,6 +307,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CreateUpdateSchedulePayload value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -274,7 +338,41 @@ public void write(JsonWriter out, CreateUpdateSchedulePayload value) public CreateUpdateSchedulePayload read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateUpdateSchedulePayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/EnableServiceResourcePayload.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/EnableServiceResourcePayload.java index dd88140..4d798fe 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/EnableServiceResourcePayload.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/EnableServiceResourcePayload.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; import java.util.UUID; /** EnableServiceResourcePayload */ @@ -61,6 +62,50 @@ public void setUpdatePolicyId(@javax.annotation.Nullable UUID updatePolicyId) { this.updatePolicyId = updatePolicyId; } + /** + * 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 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 EnableServiceResourcePayload instance itself + */ + public EnableServiceResourcePayload putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -71,12 +116,15 @@ public boolean equals(Object o) { } EnableServiceResourcePayload enableServiceResourcePayload = (EnableServiceResourcePayload) o; - return Objects.equals(this.updatePolicyId, enableServiceResourcePayload.updatePolicyId); + return Objects.equals(this.updatePolicyId, enableServiceResourcePayload.updatePolicyId) + && Objects.equals( + this.additionalProperties, + enableServiceResourcePayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(updatePolicyId); + return Objects.hash(updatePolicyId, additionalProperties); } @Override @@ -84,6 +132,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class EnableServiceResourcePayload {\n"); sb.append(" updatePolicyId: ").append(toIndentedString(updatePolicyId)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -127,17 +178,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti EnableServiceResourcePayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!EnableServiceResourcePayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `EnableServiceResourcePayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("updatePolicyId") != null && !jsonObj.get("updatePolicyId").isJsonNull()) && !jsonObj.get("updatePolicyId").isJsonPrimitive()) { @@ -167,6 +207,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, EnableServiceResourcePayload value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -174,7 +238,41 @@ public void write(JsonWriter out, EnableServiceResourcePayload value) public EnableServiceResourcePayload read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EnableServiceResourcePayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/ErrorResponse.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/ErrorResponse.java index 33fcd5e..fbc5cce 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/ErrorResponse.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/ErrorResponse.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** ErrorResponse */ @javax.annotation.Generated( @@ -86,6 +87,50 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } + /** + * 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 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 ErrorResponse instance itself + */ + public ErrorResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -96,12 +141,13 @@ public boolean equals(Object o) { } ErrorResponse errorResponse = (ErrorResponse) o; return Objects.equals(this.message, errorResponse.message) - && Objects.equals(this.status, errorResponse.status); + && Objects.equals(this.status, errorResponse.status) + && Objects.equals(this.additionalProperties, errorResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(message, status); + return Objects.hash(message, status, additionalProperties); } @Override @@ -110,6 +156,9 @@ public String toString() { sb.append("class ErrorResponse {\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -153,17 +202,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ErrorResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ErrorResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : ErrorResponse.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -204,6 +242,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, ErrorResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -211,7 +273,40 @@ public void write(JsonWriter out, ErrorResponse value) throws IOException { public ErrorResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatePoliciesResponse.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatePoliciesResponse.java index cbbf2a9..da997f4 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatePoliciesResponse.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatePoliciesResponse.java @@ -26,11 +26,11 @@ 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; -import java.util.Set; /** GetUpdatePoliciesResponse */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setItems(@javax.annotation.Nullable List items) { this.items = items; } + /** + * 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 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 GetUpdatePoliciesResponse instance itself + */ + public GetUpdatePoliciesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -79,12 +123,14 @@ public boolean equals(Object o) { return false; } GetUpdatePoliciesResponse getUpdatePoliciesResponse = (GetUpdatePoliciesResponse) o; - return Objects.equals(this.items, getUpdatePoliciesResponse.items); + return Objects.equals(this.items, getUpdatePoliciesResponse.items) + && Objects.equals( + this.additionalProperties, getUpdatePoliciesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(items); + return Objects.hash(items, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetUpdatePoliciesResponse {\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -134,17 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetUpdatePoliciesResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUpdatePoliciesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetUpdatePoliciesResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); @@ -184,6 +222,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetUpdatePoliciesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -191,7 +253,40 @@ public void write(JsonWriter out, GetUpdatePoliciesResponse value) public GetUpdatePoliciesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUpdatePoliciesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateSchedulesResponse.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateSchedulesResponse.java index f1cb719..7297c1b 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateSchedulesResponse.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateSchedulesResponse.java @@ -26,11 +26,11 @@ 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; -import java.util.Set; /** GetUpdateSchedulesResponse */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setItems(@javax.annotation.Nullable List items) { this.items = items; } + /** + * 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 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 GetUpdateSchedulesResponse instance itself + */ + public GetUpdateSchedulesResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -79,12 +123,14 @@ public boolean equals(Object o) { return false; } GetUpdateSchedulesResponse getUpdateSchedulesResponse = (GetUpdateSchedulesResponse) o; - return Objects.equals(this.items, getUpdateSchedulesResponse.items); + return Objects.equals(this.items, getUpdateSchedulesResponse.items) + && Objects.equals( + this.additionalProperties, getUpdateSchedulesResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(items); + return Objects.hash(items, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetUpdateSchedulesResponse {\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -134,17 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetUpdateSchedulesResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUpdateSchedulesResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetUpdateSchedulesResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); @@ -184,6 +222,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetUpdateSchedulesResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -191,7 +253,40 @@ public void write(JsonWriter out, GetUpdateSchedulesResponse value) public GetUpdateSchedulesResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUpdateSchedulesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateServiceResponse.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateServiceResponse.java index 04b0580..ffef551 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateServiceResponse.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdateServiceResponse.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** GetUpdateServiceResponse */ @javax.annotation.Generated( @@ -59,6 +60,50 @@ public void setEnabled(@javax.annotation.Nullable Boolean enabled) { this.enabled = enabled; } + /** + * 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 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 GetUpdateServiceResponse instance itself + */ + public GetUpdateServiceResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -68,12 +113,14 @@ public boolean equals(Object o) { return false; } GetUpdateServiceResponse getUpdateServiceResponse = (GetUpdateServiceResponse) o; - return Objects.equals(this.enabled, getUpdateServiceResponse.enabled); + return Objects.equals(this.enabled, getUpdateServiceResponse.enabled) + && Objects.equals( + this.additionalProperties, getUpdateServiceResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled); + return Objects.hash(enabled, additionalProperties); } @Override @@ -81,6 +128,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetUpdateServiceResponse {\n"); sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -123,17 +173,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetUpdateServiceResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUpdateServiceResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetUpdateServiceResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -155,6 +194,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetUpdateServiceResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -162,7 +225,40 @@ public void write(JsonWriter out, GetUpdateServiceResponse value) public GetUpdateServiceResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUpdateServiceResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatesListResponse.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatesListResponse.java index 4bc0166..d7e3e00 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatesListResponse.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/GetUpdatesListResponse.java @@ -26,11 +26,11 @@ 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; -import java.util.Set; /** GetUpdatesListResponse */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setItems(@javax.annotation.Nullable List items) { this.items = items; } + /** + * 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 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 GetUpdatesListResponse instance itself + */ + public GetUpdatesListResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -79,12 +123,14 @@ public boolean equals(Object o) { return false; } GetUpdatesListResponse getUpdatesListResponse = (GetUpdatesListResponse) o; - return Objects.equals(this.items, getUpdatesListResponse.items); + return Objects.equals(this.items, getUpdatesListResponse.items) + && Objects.equals( + this.additionalProperties, getUpdatesListResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(items); + return Objects.hash(items, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetUpdatesListResponse {\n"); sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -134,17 +183,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetUpdatesListResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetUpdatesListResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetUpdatesListResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("items") != null && !jsonObj.get("items").isJsonNull()) { JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); @@ -183,6 +221,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetUpdatesListResponse value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -190,7 +252,40 @@ public void write(JsonWriter out, GetUpdatesListResponse value) public GetUpdatesListResponse read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetUpdatesListResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/Update.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/Update.java index d7347c2..07fa770 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/Update.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/Update.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** Update */ @javax.annotation.Generated( @@ -203,6 +204,50 @@ public void setStatus(@javax.annotation.Nonnull String status) { this.status = status; } + /** + * 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 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 Update instance itself + */ + public Update putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -218,13 +263,21 @@ public boolean equals(Object o) { && Objects.equals(this.id, update.id) && Objects.equals(this.installedUpdates, update.installedUpdates) && Objects.equals(this.startDate, update.startDate) - && Objects.equals(this.status, update.status); + && Objects.equals(this.status, update.status) + && Objects.equals(this.additionalProperties, update.additionalProperties); } @Override public int hashCode() { return Objects.hash( - endDate, failReason, failedUpdates, id, installedUpdates, startDate, status); + endDate, + failReason, + failedUpdates, + id, + installedUpdates, + startDate, + status, + additionalProperties); } @Override @@ -238,6 +291,9 @@ public String toString() { sb.append(" installedUpdates: ").append(toIndentedString(installedUpdates)).append("\n"); sb.append(" startDate: ").append(toIndentedString(startDate)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -290,17 +346,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Update.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Update` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : Update.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -355,6 +400,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Update value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -362,7 +431,40 @@ public void write(JsonWriter out, Update value) throws IOException { public Update read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Update instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdatePolicy.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdatePolicy.java index ab94c2f..f324538 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdatePolicy.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdatePolicy.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** UpdatePolicy */ @javax.annotation.Generated( @@ -197,6 +198,50 @@ public void setRrule(@javax.annotation.Nullable String rrule) { this.rrule = rrule; } + /** + * 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 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 UpdatePolicy instance itself + */ + public UpdatePolicy putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -212,12 +257,21 @@ public boolean equals(Object o) { && Objects.equals(this.id, updatePolicy.id) && Objects.equals(this.maintenanceWindow, updatePolicy.maintenanceWindow) && Objects.equals(this.name, updatePolicy.name) - && Objects.equals(this.rrule, updatePolicy.rrule); + && Objects.equals(this.rrule, updatePolicy.rrule) + && Objects.equals(this.additionalProperties, updatePolicy.additionalProperties); } @Override public int hashCode() { - return Objects.hash(_default, description, enabled, id, maintenanceWindow, name, rrule); + return Objects.hash( + _default, + description, + enabled, + id, + maintenanceWindow, + name, + rrule, + additionalProperties); } @Override @@ -233,6 +287,9 @@ public String toString() { .append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -284,17 +341,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UpdatePolicy.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdatePolicy.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdatePolicy` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { @@ -342,6 +388,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdatePolicy value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -349,7 +419,40 @@ public void write(JsonWriter out, UpdatePolicy value) throws IOException { public UpdatePolicy read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdatePolicy instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateSchedule.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateSchedule.java index ac80025..5f59ad6 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateSchedule.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateSchedule.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** UpdateSchedule */ @javax.annotation.Generated( @@ -161,6 +162,50 @@ public void setId(@javax.annotation.Nonnull Integer id) { this.id = id; } + /** + * 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 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 UpdateSchedule instance itself + */ + public UpdateSchedule putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -174,12 +219,13 @@ public boolean equals(Object o) { && Objects.equals(this.maintenanceWindow, updateSchedule.maintenanceWindow) && Objects.equals(this.name, updateSchedule.name) && Objects.equals(this.rrule, updateSchedule.rrule) - && Objects.equals(this.id, updateSchedule.id); + && Objects.equals(this.id, updateSchedule.id) + && Objects.equals(this.additionalProperties, updateSchedule.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, maintenanceWindow, name, rrule, id); + return Objects.hash(enabled, maintenanceWindow, name, rrule, id, additionalProperties); } @Override @@ -193,6 +239,9 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -240,17 +289,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateSchedule.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateSchedule` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateSchedule.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -291,6 +329,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, UpdateSchedule value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -298,7 +360,40 @@ public void write(JsonWriter out, UpdateSchedule value) throws IOException { public UpdateSchedule read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateSchedule instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateScheduleCreateRequest.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateScheduleCreateRequest.java index e23da78..5d23e4a 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateScheduleCreateRequest.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateScheduleCreateRequest.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** UpdateScheduleCreateRequest */ @javax.annotation.Generated( @@ -137,6 +138,50 @@ public void setRrule(@javax.annotation.Nonnull String rrule) { this.rrule = rrule; } + /** + * 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 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 UpdateScheduleCreateRequest instance itself + */ + public UpdateScheduleCreateRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -150,12 +195,15 @@ public boolean equals(Object o) { && Objects.equals( this.maintenanceWindow, updateScheduleCreateRequest.maintenanceWindow) && Objects.equals(this.name, updateScheduleCreateRequest.name) - && Objects.equals(this.rrule, updateScheduleCreateRequest.rrule); + && Objects.equals(this.rrule, updateScheduleCreateRequest.rrule) + && Objects.equals( + this.additionalProperties, + updateScheduleCreateRequest.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, maintenanceWindow, name, rrule); + return Objects.hash(enabled, maintenanceWindow, name, rrule, additionalProperties); } @Override @@ -168,6 +216,9 @@ public String toString() { .append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -214,17 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateScheduleCreateRequest.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateScheduleCreateRequest` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateScheduleCreateRequest.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,6 +307,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateScheduleCreateRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -274,7 +338,41 @@ public void write(JsonWriter out, UpdateScheduleCreateRequest value) public UpdateScheduleCreateRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateScheduleCreateRequest instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); } diff --git a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateUpdateSchedulePayload.java b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateUpdateSchedulePayload.java index d010d1a..a7fbf7a 100644 --- a/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateUpdateSchedulePayload.java +++ b/services/serverupdate/src/main/java/cloud/stackit/sdk/serverupdate/model/UpdateUpdateSchedulePayload.java @@ -24,10 +24,11 @@ import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Arrays; +import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** UpdateUpdateSchedulePayload */ @javax.annotation.Generated( @@ -137,6 +138,50 @@ public void setRrule(@javax.annotation.Nonnull String rrule) { this.rrule = rrule; } + /** + * 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 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 UpdateUpdateSchedulePayload instance itself + */ + public UpdateUpdateSchedulePayload putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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) { @@ -150,12 +195,15 @@ public boolean equals(Object o) { && Objects.equals( this.maintenanceWindow, updateUpdateSchedulePayload.maintenanceWindow) && Objects.equals(this.name, updateUpdateSchedulePayload.name) - && Objects.equals(this.rrule, updateUpdateSchedulePayload.rrule); + && Objects.equals(this.rrule, updateUpdateSchedulePayload.rrule) + && Objects.equals( + this.additionalProperties, + updateUpdateSchedulePayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(enabled, maintenanceWindow, name, rrule); + return Objects.hash(enabled, maintenanceWindow, name, rrule, additionalProperties); } @Override @@ -168,6 +216,9 @@ public String toString() { .append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" rrule: ").append(toIndentedString(rrule)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -214,17 +265,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateUpdateSchedulePayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateUpdateSchedulePayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } - // check to make sure all required properties/fields are present in the JSON string for (String requiredField : UpdateUpdateSchedulePayload.openapiRequiredFields) { if (jsonElement.getAsJsonObject().get(requiredField) == null) { @@ -267,6 +307,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateUpdateSchedulePayload value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -274,7 +338,41 @@ public void write(JsonWriter out, UpdateUpdateSchedulePayload value) public UpdateUpdateSchedulePayload read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); - return thisAdapter.fromJsonTree(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateUpdateSchedulePayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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( + "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(); }