From 6c2a3b1c0af0f85e9d90169666c2765889980999 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Fri, 30 Jan 2026 16:38:14 +0000 Subject: [PATCH] Generate alb --- services/alb/oas_commit | 1 + .../sdk/alb/model/ActiveHealthCheck.java | 127 ++++++++++-- .../sdk/alb/model/CertificateConfig.java | 125 +++++++++-- .../sdk/alb/model/CookiePersistence.java | 126 +++++++++-- .../alb/model/CreateCredentialsPayload.java | 126 +++++++++-- .../alb/model/CreateCredentialsResponse.java | 126 +++++++++-- .../alb/model/CreateLoadBalancerPayload.java | 125 +++++++++-- .../sdk/alb/model/CredentialsResponse.java | 126 +++++++++-- .../sdk/alb/model/GetCredentialsResponse.java | 126 +++++++++-- .../sdk/alb/model/GetQuotaResponse.java | 195 ++++++++++++++++-- .../stackit/sdk/alb/model/HostConfig.java | 124 +++++++++-- .../stackit/sdk/alb/model/HttpHeader.java | 125 +++++++++-- .../sdk/alb/model/HttpHealthChecks.java | 124 +++++++++-- .../alb/model/ListCredentialsResponse.java | 125 +++++++++-- .../alb/model/ListLoadBalancersResponse.java | 125 +++++++++-- .../sdk/alb/model/ListPlansResponse.java | 125 +++++++++-- .../cloud/stackit/sdk/alb/model/Listener.java | 125 +++++++++-- .../stackit/sdk/alb/model/LoadBalancer.java | 124 +++++++++-- .../sdk/alb/model/LoadBalancerError.java | 126 +++++++++-- .../sdk/alb/model/LoadBalancerOptions.java | 135 ++++++++++-- .../LoadbalancerOptionAccessControl.java | 128 ++++++++++-- .../sdk/alb/model/LoadbalancerOptionLogs.java | 126 +++++++++-- .../alb/model/LoadbalancerOptionMetrics.java | 126 +++++++++-- .../LoadbalancerOptionObservability.java | 128 ++++++++++-- .../cloud/stackit/sdk/alb/model/Network.java | 125 +++++++++-- .../cloud/stackit/sdk/alb/model/Path.java | 125 +++++++++-- .../stackit/sdk/alb/model/PlanDetails.java | 132 ++++++++++-- .../sdk/alb/model/ProtocolOptionsHTTP.java | 125 +++++++++-- .../sdk/alb/model/ProtocolOptionsHTTPS.java | 126 +++++++++-- .../stackit/sdk/alb/model/QueryParameter.java | 125 +++++++++-- .../cloud/stackit/sdk/alb/model/Rule.java | 130 ++++++++++-- .../stackit/sdk/alb/model/SecurityGroup.java | 125 +++++++++-- .../cloud/stackit/sdk/alb/model/Status.java | 124 +++++++++-- .../cloud/stackit/sdk/alb/model/Target.java | 125 +++++++++-- .../stackit/sdk/alb/model/TargetPool.java | 125 +++++++++-- .../sdk/alb/model/TargetPoolTlsConfig.java | 126 +++++++++-- .../alb/model/UpdateCredentialsPayload.java | 126 +++++++++-- .../alb/model/UpdateCredentialsResponse.java | 126 +++++++++-- .../alb/model/UpdateLoadBalancerPayload.java | 125 +++++++++-- .../alb/model/UpdateTargetPoolPayload.java | 126 +++++++++-- 40 files changed, 4398 insertions(+), 587 deletions(-) create mode 100644 services/alb/oas_commit diff --git a/services/alb/oas_commit b/services/alb/oas_commit new file mode 100644 index 0000000..148a7d9 --- /dev/null +++ b/services/alb/oas_commit @@ -0,0 +1 @@ +ed4e4fbee2f5db4d95725108fb3d736e5363fb2f diff --git a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ActiveHealthCheck.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ActiveHealthCheck.java index 5db91e6..afab877 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ActiveHealthCheck.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ActiveHealthCheck.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; /** Set this to customize active health checks for targets in this pool. */ @javax.annotation.Generated( @@ -176,6 +177,50 @@ public void setUnhealthyThreshold(@javax.annotation.Nullable Integer unhealthyTh this.unhealthyThreshold = unhealthyThreshold; } + /** + * 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 ActiveHealthCheck instance itself + */ + public ActiveHealthCheck 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) { @@ -190,7 +235,9 @@ public boolean equals(Object o) { && Objects.equals(this.interval, activeHealthCheck.interval) && Objects.equals(this.intervalJitter, activeHealthCheck.intervalJitter) && Objects.equals(this.timeout, activeHealthCheck.timeout) - && Objects.equals(this.unhealthyThreshold, activeHealthCheck.unhealthyThreshold); + && Objects.equals(this.unhealthyThreshold, activeHealthCheck.unhealthyThreshold) + && Objects.equals( + this.additionalProperties, activeHealthCheck.additionalProperties); } @Override @@ -201,7 +248,8 @@ public int hashCode() { interval, intervalJitter, timeout, - unhealthyThreshold); + unhealthyThreshold, + additionalProperties); } @Override @@ -216,6 +264,9 @@ public String toString() { sb.append(" unhealthyThreshold: ") .append(toIndentedString(unhealthyThreshold)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -266,17 +317,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ActiveHealthCheck.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ActiveHealthCheck.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ActiveHealthCheck` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `httpHealthChecks` if (jsonObj.get("httpHealthChecks") != null @@ -323,6 +363,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ActiveHealthCheck 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); } @@ -330,7 +394,40 @@ public void write(JsonWriter out, ActiveHealthCheck value) public ActiveHealthCheck 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 + ActiveHealthCheck 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CertificateConfig.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CertificateConfig.java index acbaa6b..decfd5a 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CertificateConfig.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CertificateConfig.java @@ -25,11 +25,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; /** TLS termination certificate configuration. */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setCertificateIds(@javax.annotation.Nullable List certificat this.certificateIds = certificateIds; } + /** + * 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 CertificateConfig instance itself + */ + public CertificateConfig 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; } CertificateConfig certificateConfig = (CertificateConfig) o; - return Objects.equals(this.certificateIds, certificateConfig.certificateIds); + return Objects.equals(this.certificateIds, certificateConfig.certificateIds) + && Objects.equals( + this.additionalProperties, certificateConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificateIds); + return Objects.hash(certificateIds, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CertificateConfig {\n"); sb.append(" certificateIds: ").append(toIndentedString(certificateIds)).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 CertificateConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CertificateConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CertificateConfig` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("certificateIds") != null @@ -174,6 +212,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CertificateConfig 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); } @@ -181,7 +243,40 @@ public void write(JsonWriter out, CertificateConfig value) public CertificateConfig 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 + CertificateConfig 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CookiePersistence.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CookiePersistence.java index 5c71ebe..fca17af 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CookiePersistence.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CookiePersistence.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; /** CookiePersistence contains the cookie-based session persistence configuration. */ @javax.annotation.Generated( @@ -83,6 +84,50 @@ public void setTtl(@javax.annotation.Nullable String ttl) { this.ttl = ttl; } + /** + * 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 CookiePersistence instance itself + */ + public CookiePersistence 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) { @@ -93,12 +138,14 @@ public boolean equals(Object o) { } CookiePersistence cookiePersistence = (CookiePersistence) o; return Objects.equals(this.name, cookiePersistence.name) - && Objects.equals(this.ttl, cookiePersistence.ttl); + && Objects.equals(this.ttl, cookiePersistence.ttl) + && Objects.equals( + this.additionalProperties, cookiePersistence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name, ttl); + return Objects.hash(name, ttl, additionalProperties); } @Override @@ -107,6 +154,9 @@ public String toString() { sb.append("class CookiePersistence {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" ttl: ").append(toIndentedString(ttl)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -149,17 +199,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CookiePersistence.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CookiePersistence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CookiePersistence` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { @@ -194,6 +233,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CookiePersistence 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); } @@ -201,7 +264,40 @@ public void write(JsonWriter out, CookiePersistence value) public CookiePersistence 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 + CookiePersistence 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsPayload.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsPayload.java index 43e88ad..fa9b9d0 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsPayload.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsPayload.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; /** CreateCredentialsPayload */ @javax.annotation.Generated( @@ -107,6 +108,50 @@ public void setUsername(@javax.annotation.Nullable String username) { this.username = username; } + /** + * 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 CreateCredentialsPayload instance itself + */ + public CreateCredentialsPayload 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) { @@ -118,12 +163,14 @@ public boolean equals(Object o) { CreateCredentialsPayload createCredentialsPayload = (CreateCredentialsPayload) o; return Objects.equals(this.displayName, createCredentialsPayload.displayName) && Objects.equals(this.password, createCredentialsPayload.password) - && Objects.equals(this.username, createCredentialsPayload.username); + && Objects.equals(this.username, createCredentialsPayload.username) + && Objects.equals( + this.additionalProperties, createCredentialsPayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(displayName, password, username); + return Objects.hash(displayName, password, username, additionalProperties); } @Override @@ -133,6 +180,9 @@ public String toString() { sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -175,17 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CreateCredentialsPayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCredentialsPayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CreateCredentialsPayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) { @@ -228,6 +267,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CreateCredentialsPayload 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); } @@ -235,7 +298,40 @@ public void write(JsonWriter out, CreateCredentialsPayload value) public CreateCredentialsPayload 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 + CreateCredentialsPayload 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsResponse.java index 67d2f49..423db79 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateCredentialsResponse.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; /** CreateCredentialsResponse */ @javax.annotation.Generated( @@ -60,6 +61,50 @@ public void setCredential(@javax.annotation.Nullable CredentialsResponse credent this.credential = credential; } + /** + * 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 CreateCredentialsResponse instance itself + */ + public CreateCredentialsResponse 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) { @@ -69,12 +114,14 @@ public boolean equals(Object o) { return false; } CreateCredentialsResponse createCredentialsResponse = (CreateCredentialsResponse) o; - return Objects.equals(this.credential, createCredentialsResponse.credential); + return Objects.equals(this.credential, createCredentialsResponse.credential) + && Objects.equals( + this.additionalProperties, createCredentialsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credential); + return Objects.hash(credential, additionalProperties); } @Override @@ -82,6 +129,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class CreateCredentialsResponse {\n"); sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -124,17 +174,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CreateCredentialsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateCredentialsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CreateCredentialsResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `credential` if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { @@ -160,6 +199,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CreateCredentialsResponse 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); } @@ -167,7 +230,40 @@ public void write(JsonWriter out, CreateCredentialsResponse value) public CreateCredentialsResponse 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 + CreateCredentialsResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateLoadBalancerPayload.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateLoadBalancerPayload.java index 875bb13..5c1fc00 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateLoadBalancerPayload.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CreateLoadBalancerPayload.java @@ -32,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** CreateLoadBalancerPayload */ @javax.annotation.Generated( @@ -488,6 +487,50 @@ public void setTargetPools(@javax.annotation.Nullable List targetPoo return version; } + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateLoadBalancerPayload instance itself + */ + public CreateLoadBalancerPayload putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + 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) { @@ -517,7 +560,9 @@ public boolean equals(Object o) { && Objects.equals(this.targetPools, createLoadBalancerPayload.targetPools) && Objects.equals( this.targetSecurityGroup, createLoadBalancerPayload.targetSecurityGroup) - && Objects.equals(this.version, createLoadBalancerPayload.version); + && Objects.equals(this.version, createLoadBalancerPayload.version) + && Objects.equals( + this.additionalProperties, createLoadBalancerPayload.additionalProperties); } @Override @@ -538,7 +583,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -567,6 +613,9 @@ public String toString() { .append(toIndentedString(targetSecurityGroup)) .append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -627,17 +676,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CreateLoadBalancerPayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CreateLoadBalancerPayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CreateLoadBalancerPayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); @@ -798,6 +836,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CreateLoadBalancerPayload value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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); } @@ -805,7 +867,40 @@ public void write(JsonWriter out, CreateLoadBalancerPayload value) public CreateLoadBalancerPayload 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 + CreateLoadBalancerPayload 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/alb/src/main/java/cloud/stackit/sdk/alb/model/CredentialsResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CredentialsResponse.java index 600b869..0d5c8eb 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CredentialsResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/CredentialsResponse.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; /** CredentialsResponse */ @javax.annotation.Generated( @@ -128,6 +129,50 @@ public void setUsername(@javax.annotation.Nullable String username) { this.username = username; } + /** + * 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 CredentialsResponse instance itself + */ + public CredentialsResponse 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) { @@ -140,12 +185,14 @@ public boolean equals(Object o) { return Objects.equals(this.credentialsRef, credentialsResponse.credentialsRef) && Objects.equals(this.displayName, credentialsResponse.displayName) && Objects.equals(this.region, credentialsResponse.region) - && Objects.equals(this.username, credentialsResponse.username); + && Objects.equals(this.username, credentialsResponse.username) + && Objects.equals( + this.additionalProperties, credentialsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credentialsRef, displayName, region, username); + return Objects.hash(credentialsRef, displayName, region, username, additionalProperties); } @Override @@ -156,6 +203,9 @@ public String toString() { sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" region: ").append(toIndentedString(region)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -200,17 +250,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti CredentialsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!CredentialsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `CredentialsResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) && !jsonObj.get("credentialsRef").isJsonPrimitive()) { @@ -259,6 +298,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, CredentialsResponse 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); } @@ -266,7 +329,40 @@ public void write(JsonWriter out, CredentialsResponse value) public CredentialsResponse 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 + CredentialsResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/GetCredentialsResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetCredentialsResponse.java index 6f17b91..01f19dc 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetCredentialsResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetCredentialsResponse.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; /** GetCredentialsResponse */ @javax.annotation.Generated( @@ -60,6 +61,50 @@ public void setCredential(@javax.annotation.Nullable CredentialsResponse credent this.credential = credential; } + /** + * 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 GetCredentialsResponse instance itself + */ + public GetCredentialsResponse 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) { @@ -69,12 +114,14 @@ public boolean equals(Object o) { return false; } GetCredentialsResponse getCredentialsResponse = (GetCredentialsResponse) o; - return Objects.equals(this.credential, getCredentialsResponse.credential); + return Objects.equals(this.credential, getCredentialsResponse.credential) + && Objects.equals( + this.additionalProperties, getCredentialsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credential); + return Objects.hash(credential, additionalProperties); } @Override @@ -82,6 +129,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetCredentialsResponse {\n"); sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -124,17 +174,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetCredentialsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetCredentialsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetCredentialsResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `credential` if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { @@ -159,6 +198,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetCredentialsResponse 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); } @@ -166,7 +229,40 @@ public void write(JsonWriter out, GetCredentialsResponse value) public GetCredentialsResponse 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 + GetCredentialsResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/GetQuotaResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetQuotaResponse.java index 4045a45..bcb1059 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetQuotaResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/GetQuotaResponse.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; /** GetQuotaResponse */ @@ -55,6 +56,16 @@ public class GetQuotaResponse { @SerializedName(SERIALIZED_NAME_REGION) @javax.annotation.Nullable private String region; + public static final String SERIALIZED_NAME_USED_CREDENTIALS = "usedCredentials"; + + @SerializedName(SERIALIZED_NAME_USED_CREDENTIALS) + @javax.annotation.Nullable private Integer usedCredentials; + + public static final String SERIALIZED_NAME_USED_LOAD_BALANCERS = "usedLoadBalancers"; + + @SerializedName(SERIALIZED_NAME_USED_LOAD_BALANCERS) + @javax.annotation.Nullable private Integer usedLoadBalancers; + public GetQuotaResponse() {} public GetQuotaResponse(UUID projectId, String region) { @@ -118,6 +129,89 @@ public void setMaxLoadBalancers(@javax.annotation.Nullable Integer maxLoadBalanc return region; } + public GetQuotaResponse usedCredentials(@javax.annotation.Nullable Integer usedCredentials) { + this.usedCredentials = usedCredentials; + return this; + } + + /** + * The number of observability credentials that are currently existing in this project. minimum: + * -1 maximum: 1000000 + * + * @return usedCredentials + */ + @javax.annotation.Nullable public Integer getUsedCredentials() { + return usedCredentials; + } + + public void setUsedCredentials(@javax.annotation.Nullable Integer usedCredentials) { + this.usedCredentials = usedCredentials; + } + + public GetQuotaResponse usedLoadBalancers( + @javax.annotation.Nullable Integer usedLoadBalancers) { + this.usedLoadBalancers = usedLoadBalancers; + return this; + } + + /** + * The number of load balancing servers that are currently existing in this project. minimum: -1 + * maximum: 1000000 + * + * @return usedLoadBalancers + */ + @javax.annotation.Nullable public Integer getUsedLoadBalancers() { + return usedLoadBalancers; + } + + public void setUsedLoadBalancers(@javax.annotation.Nullable Integer usedLoadBalancers) { + this.usedLoadBalancers = usedLoadBalancers; + } + + /** + * 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 GetQuotaResponse instance itself + */ + public GetQuotaResponse 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) { @@ -130,12 +224,22 @@ public boolean equals(Object o) { return Objects.equals(this.maxCredentials, getQuotaResponse.maxCredentials) && Objects.equals(this.maxLoadBalancers, getQuotaResponse.maxLoadBalancers) && Objects.equals(this.projectId, getQuotaResponse.projectId) - && Objects.equals(this.region, getQuotaResponse.region); + && Objects.equals(this.region, getQuotaResponse.region) + && Objects.equals(this.usedCredentials, getQuotaResponse.usedCredentials) + && Objects.equals(this.usedLoadBalancers, getQuotaResponse.usedLoadBalancers) + && Objects.equals(this.additionalProperties, getQuotaResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(maxCredentials, maxLoadBalancers, projectId, region); + return Objects.hash( + maxCredentials, + maxLoadBalancers, + projectId, + region, + usedCredentials, + usedLoadBalancers, + additionalProperties); } @Override @@ -146,6 +250,13 @@ public String toString() { sb.append(" maxLoadBalancers: ").append(toIndentedString(maxLoadBalancers)).append("\n"); sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" usedCredentials: ").append(toIndentedString(usedCredentials)).append("\n"); + sb.append(" usedLoadBalancers: ") + .append(toIndentedString(usedLoadBalancers)) + .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -168,7 +279,13 @@ private String toIndentedString(Object o) { // a set of all properties/fields (JSON key names) openapiFields = new HashSet( - Arrays.asList("maxCredentials", "maxLoadBalancers", "projectId", "region")); + Arrays.asList( + "maxCredentials", + "maxLoadBalancers", + "projectId", + "region", + "usedCredentials", + "usedLoadBalancers")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -190,17 +307,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti GetQuotaResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!GetQuotaResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `GetQuotaResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("projectId") != null && !jsonObj.get("projectId").isJsonNull()) && !jsonObj.get("projectId").isJsonPrimitive()) { @@ -235,6 +341,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, GetQuotaResponse 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); } @@ -242,7 +372,40 @@ public void write(JsonWriter out, GetQuotaResponse value) public GetQuotaResponse 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 + GetQuotaResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/HostConfig.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HostConfig.java index 4a52cd2..58841eb 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HostConfig.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HostConfig.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; /** HostConfig */ @javax.annotation.Generated( @@ -93,6 +93,50 @@ public void setRules(@javax.annotation.Nullable List rules) { this.rules = rules; } + /** + * 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 HostConfig instance itself + */ + public HostConfig 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) { @@ -103,12 +147,13 @@ public boolean equals(Object o) { } HostConfig hostConfig = (HostConfig) o; return Objects.equals(this.host, hostConfig.host) - && Objects.equals(this.rules, hostConfig.rules); + && Objects.equals(this.rules, hostConfig.rules) + && Objects.equals(this.additionalProperties, hostConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(host, rules); + return Objects.hash(host, rules, additionalProperties); } @Override @@ -117,6 +162,9 @@ public String toString() { sb.append("class HostConfig {\n"); sb.append(" host: ").append(toIndentedString(host)).append("\n"); sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -159,17 +207,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti HostConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HostConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `HostConfig` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("host") != null && !jsonObj.get("host").isJsonNull()) && !jsonObj.get("host").isJsonPrimitive()) { @@ -214,6 +251,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HostConfig 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); } @@ -221,7 +282,40 @@ public void write(JsonWriter out, HostConfig value) throws IOException { public HostConfig 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 + HostConfig 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/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHeader.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHeader.java index fbeaf89..e97bc24 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHeader.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHeader.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; /** HttpHeader */ @javax.annotation.Generated( @@ -82,6 +83,50 @@ public void setName(@javax.annotation.Nullable String name) { this.name = name; } + /** + * 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 HttpHeader instance itself + */ + public HttpHeader 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) { @@ -92,12 +137,13 @@ public boolean equals(Object o) { } HttpHeader httpHeader = (HttpHeader) o; return Objects.equals(this.exactMatch, httpHeader.exactMatch) - && Objects.equals(this.name, httpHeader.name); + && Objects.equals(this.name, httpHeader.name) + && Objects.equals(this.additionalProperties, httpHeader.additionalProperties); } @Override public int hashCode() { - return Objects.hash(exactMatch, name); + return Objects.hash(exactMatch, name, additionalProperties); } @Override @@ -106,6 +152,9 @@ public String toString() { sb.append("class HttpHeader {\n"); sb.append(" exactMatch: ").append(toIndentedString(exactMatch)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -148,17 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti HttpHeader.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HttpHeader.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `HttpHeader` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("exactMatch") != null && !jsonObj.get("exactMatch").isJsonNull()) && !jsonObj.get("exactMatch").isJsonPrimitive()) { @@ -192,6 +230,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, HttpHeader 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); } @@ -199,7 +261,40 @@ public void write(JsonWriter out, HttpHeader value) throws IOException { public HttpHeader 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 + HttpHeader 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/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHealthChecks.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHealthChecks.java index 8bc34a1..3badec0 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHealthChecks.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/HttpHealthChecks.java @@ -25,11 +25,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; /** Options for the HTTP health checking. */ @javax.annotation.Generated( @@ -92,6 +92,50 @@ public void setPath(@javax.annotation.Nullable String path) { this.path = path; } + /** + * 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 HttpHealthChecks instance itself + */ + public HttpHealthChecks 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) { @@ -102,12 +146,13 @@ public boolean equals(Object o) { } HttpHealthChecks httpHealthChecks = (HttpHealthChecks) o; return Objects.equals(this.okStatuses, httpHealthChecks.okStatuses) - && Objects.equals(this.path, httpHealthChecks.path); + && Objects.equals(this.path, httpHealthChecks.path) + && Objects.equals(this.additionalProperties, httpHealthChecks.additionalProperties); } @Override public int hashCode() { - return Objects.hash(okStatuses, path); + return Objects.hash(okStatuses, path, additionalProperties); } @Override @@ -116,6 +161,9 @@ public String toString() { sb.append("class HttpHealthChecks {\n"); sb.append(" okStatuses: ").append(toIndentedString(okStatuses)).append("\n"); sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -158,17 +206,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti HttpHealthChecks.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!HttpHealthChecks.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `HttpHealthChecks` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("okStatuses") != null @@ -205,6 +242,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, HttpHealthChecks 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); } @@ -212,7 +273,40 @@ public void write(JsonWriter out, HttpHealthChecks value) public HttpHealthChecks 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 + HttpHealthChecks 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/alb/src/main/java/cloud/stackit/sdk/alb/model/ListCredentialsResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListCredentialsResponse.java index add1e16..9415a27 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListCredentialsResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListCredentialsResponse.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; /** ListCredentialsResponse */ @javax.annotation.Generated( @@ -71,6 +71,50 @@ public void setCredentials(@javax.annotation.Nullable List this.credentials = credentials; } + /** + * 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 ListCredentialsResponse instance itself + */ + public ListCredentialsResponse 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) { @@ -80,12 +124,14 @@ public boolean equals(Object o) { return false; } ListCredentialsResponse listCredentialsResponse = (ListCredentialsResponse) o; - return Objects.equals(this.credentials, listCredentialsResponse.credentials); + return Objects.equals(this.credentials, listCredentialsResponse.credentials) + && Objects.equals( + this.additionalProperties, listCredentialsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credentials); + return Objects.hash(credentials, additionalProperties); } @Override @@ -93,6 +139,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListCredentialsResponse {\n"); sb.append(" credentials: ").append(toIndentedString(credentials)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -135,17 +184,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ListCredentialsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListCredentialsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ListCredentialsResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("credentials") != null && !jsonObj.get("credentials").isJsonNull()) { JsonArray jsonArraycredentials = jsonObj.getAsJsonArray("credentials"); @@ -185,6 +223,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ListCredentialsResponse 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); } @@ -192,7 +254,40 @@ public void write(JsonWriter out, ListCredentialsResponse value) public ListCredentialsResponse 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 + ListCredentialsResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/ListLoadBalancersResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListLoadBalancersResponse.java index 2572e97..df79f08 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListLoadBalancersResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListLoadBalancersResponse.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; /** ListLoadBalancersResponse */ @javax.annotation.Generated( @@ -94,6 +94,50 @@ public void setNextPageId(@javax.annotation.Nullable String nextPageId) { this.nextPageId = nextPageId; } + /** + * 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 ListLoadBalancersResponse instance itself + */ + public ListLoadBalancersResponse 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) { @@ -104,12 +148,14 @@ public boolean equals(Object o) { } ListLoadBalancersResponse listLoadBalancersResponse = (ListLoadBalancersResponse) o; return Objects.equals(this.loadBalancers, listLoadBalancersResponse.loadBalancers) - && Objects.equals(this.nextPageId, listLoadBalancersResponse.nextPageId); + && Objects.equals(this.nextPageId, listLoadBalancersResponse.nextPageId) + && Objects.equals( + this.additionalProperties, listLoadBalancersResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(loadBalancers, nextPageId); + return Objects.hash(loadBalancers, nextPageId, additionalProperties); } @Override @@ -118,6 +164,9 @@ public String toString() { sb.append("class ListLoadBalancersResponse {\n"); sb.append(" loadBalancers: ").append(toIndentedString(loadBalancers)).append("\n"); sb.append(" nextPageId: ").append(toIndentedString(nextPageId)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -160,17 +209,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ListLoadBalancersResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListLoadBalancersResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ListLoadBalancersResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("loadBalancers") != null && !jsonObj.get("loadBalancers").isJsonNull()) { JsonArray jsonArrayloadBalancers = jsonObj.getAsJsonArray("loadBalancers"); @@ -217,6 +255,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ListLoadBalancersResponse 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); } @@ -224,7 +286,40 @@ public void write(JsonWriter out, ListLoadBalancersResponse value) public ListLoadBalancersResponse 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 + ListLoadBalancersResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/ListPlansResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListPlansResponse.java index 2afb14d..0c47586 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListPlansResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ListPlansResponse.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; /** ListPlansResponse */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setValidPlans(@javax.annotation.Nullable List validPlan this.validPlans = validPlans; } + /** + * 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 ListPlansResponse instance itself + */ + public ListPlansResponse 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; } ListPlansResponse listPlansResponse = (ListPlansResponse) o; - return Objects.equals(this.validPlans, listPlansResponse.validPlans); + return Objects.equals(this.validPlans, listPlansResponse.validPlans) + && Objects.equals( + this.additionalProperties, listPlansResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(validPlans); + return Objects.hash(validPlans, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ListPlansResponse {\n"); sb.append(" validPlans: ").append(toIndentedString(validPlans)).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 ListPlansResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ListPlansResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ListPlansResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("validPlans") != null && !jsonObj.get("validPlans").isJsonNull()) { JsonArray jsonArrayvalidPlans = jsonObj.getAsJsonArray("validPlans"); @@ -183,6 +221,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ListPlansResponse 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, ListPlansResponse value) public ListPlansResponse 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 + ListPlansResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Listener.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Listener.java index 448b863..30bd5c8 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Listener.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Listener.java @@ -25,10 +25,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; /** Listener */ @javax.annotation.Generated( @@ -235,6 +236,50 @@ public void setWafConfigName(@javax.annotation.Nullable String wafConfigName) { this.wafConfigName = wafConfigName; } + /** + * 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 Listener instance itself + */ + public Listener 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) { @@ -249,12 +294,13 @@ public boolean equals(Object o) { && Objects.equals(this.name, listener.name) && Objects.equals(this.port, listener.port) && Objects.equals(this.protocol, listener.protocol) - && Objects.equals(this.wafConfigName, listener.wafConfigName); + && Objects.equals(this.wafConfigName, listener.wafConfigName) + && Objects.equals(this.additionalProperties, listener.additionalProperties); } @Override public int hashCode() { - return Objects.hash(http, https, name, port, protocol, wafConfigName); + return Objects.hash(http, https, name, port, protocol, wafConfigName, additionalProperties); } @Override @@ -267,6 +313,9 @@ public String toString() { sb.append(" port: ").append(toIndentedString(port)).append("\n"); sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); sb.append(" wafConfigName: ").append(toIndentedString(wafConfigName)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -312,17 +361,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Listener.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Listener.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Listener` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `http` if (jsonObj.get("http") != null && !jsonObj.get("http").isJsonNull()) { @@ -375,6 +413,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Listener 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); } @@ -382,7 +444,40 @@ public void write(JsonWriter out, Listener value) throws IOException { public Listener 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 + Listener 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancer.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancer.java index 25ffd5c..98d926f 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancer.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancer.java @@ -32,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** LoadBalancer */ @javax.annotation.Generated( @@ -484,6 +483,50 @@ public void setTargetPools(@javax.annotation.Nullable List targetPoo return version; } + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map 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 LoadBalancer instance itself + */ + public LoadBalancer 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) { @@ -511,7 +554,8 @@ public boolean equals(Object o) { && Objects.equals(this.status, loadBalancer.status) && Objects.equals(this.targetPools, loadBalancer.targetPools) && Objects.equals(this.targetSecurityGroup, loadBalancer.targetSecurityGroup) - && Objects.equals(this.version, loadBalancer.version); + && Objects.equals(this.version, loadBalancer.version) + && Objects.equals(this.additionalProperties, loadBalancer.additionalProperties); } @Override @@ -532,7 +576,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -561,6 +606,9 @@ public String toString() { .append(toIndentedString(targetSecurityGroup)) .append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -621,17 +669,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadBalancer.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadBalancer.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadBalancer` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); @@ -790,6 +827,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, LoadBalancer 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); } @@ -797,7 +858,40 @@ public void write(JsonWriter out, LoadBalancer value) throws IOException { public LoadBalancer 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 + LoadBalancer 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerError.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerError.java index 9e42e03..34052b1 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerError.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerError.java @@ -25,10 +25,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; /** LoadBalancerError */ @javax.annotation.Generated( @@ -161,6 +162,50 @@ public void setType(@javax.annotation.Nullable TypeEnum type) { this.type = type; } + /** + * 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 LoadBalancerError instance itself + */ + public LoadBalancerError 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) { @@ -171,12 +216,14 @@ public boolean equals(Object o) { } LoadBalancerError loadBalancerError = (LoadBalancerError) o; return Objects.equals(this.description, loadBalancerError.description) - && Objects.equals(this.type, loadBalancerError.type); + && Objects.equals(this.type, loadBalancerError.type) + && Objects.equals( + this.additionalProperties, loadBalancerError.additionalProperties); } @Override public int hashCode() { - return Objects.hash(description, type); + return Objects.hash(description, type, additionalProperties); } @Override @@ -185,6 +232,9 @@ public String toString() { sb.append("class LoadBalancerError {\n"); sb.append(" description: ").append(toIndentedString(description)).append("\n"); sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -227,17 +277,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadBalancerError.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadBalancerError.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadBalancerError` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { @@ -276,6 +315,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadBalancerError 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); } @@ -283,7 +346,40 @@ public void write(JsonWriter out, LoadBalancerError value) public LoadBalancerError 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 + LoadBalancerError 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerOptions.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerOptions.java index 1e7096d..2166c1a 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerOptions.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadBalancerOptions.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; /** * Defines any optional functionality you want to have enabled on your Application Load Balancer. @@ -85,7 +86,9 @@ public LoadBalancerOptions ephemeralAddress( } /** - * Get ephemeralAddress + * This option automates the handling of the external IP address for an Application Load + * Balancer. If set to true a new IP address will be automatically created. It will also be + * automatically deleted when the Load Balancer is deleted. * * @return ephemeralAddress */ @@ -137,6 +140,50 @@ public void setPrivateNetworkOnly(@javax.annotation.Nullable Boolean privateNetw this.privateNetworkOnly = privateNetworkOnly; } + /** + * 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 LoadBalancerOptions instance itself + */ + public LoadBalancerOptions 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) { @@ -149,12 +196,19 @@ public boolean equals(Object o) { return Objects.equals(this.accessControl, loadBalancerOptions.accessControl) && Objects.equals(this.ephemeralAddress, loadBalancerOptions.ephemeralAddress) && Objects.equals(this.observability, loadBalancerOptions.observability) - && Objects.equals(this.privateNetworkOnly, loadBalancerOptions.privateNetworkOnly); + && Objects.equals(this.privateNetworkOnly, loadBalancerOptions.privateNetworkOnly) + && Objects.equals( + this.additionalProperties, loadBalancerOptions.additionalProperties); } @Override public int hashCode() { - return Objects.hash(accessControl, ephemeralAddress, observability, privateNetworkOnly); + return Objects.hash( + accessControl, + ephemeralAddress, + observability, + privateNetworkOnly, + additionalProperties); } @Override @@ -167,6 +221,9 @@ public String toString() { sb.append(" privateNetworkOnly: ") .append(toIndentedString(privateNetworkOnly)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -215,17 +272,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadBalancerOptions.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadBalancerOptions.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadBalancerOptions` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `accessControl` if (jsonObj.get("accessControl") != null && !jsonObj.get("accessControl").isJsonNull()) { @@ -254,6 +300,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadBalancerOptions 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); } @@ -261,7 +331,40 @@ public void write(JsonWriter out, LoadBalancerOptions value) public LoadBalancerOptions 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 + LoadBalancerOptions 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionAccessControl.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionAccessControl.java index 4312a8f..50ee209 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionAccessControl.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionAccessControl.java @@ -25,11 +25,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; /** Use this option to limit the IP ranges that can use the Application Load Balancer. */ @javax.annotation.Generated( @@ -72,6 +72,50 @@ public void setAllowedSourceRanges( this.allowedSourceRanges = allowedSourceRanges; } + /** + * 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 LoadbalancerOptionAccessControl instance itself + */ + public LoadbalancerOptionAccessControl 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) { @@ -83,12 +127,16 @@ public boolean equals(Object o) { LoadbalancerOptionAccessControl loadbalancerOptionAccessControl = (LoadbalancerOptionAccessControl) o; return Objects.equals( - this.allowedSourceRanges, loadbalancerOptionAccessControl.allowedSourceRanges); + this.allowedSourceRanges, + loadbalancerOptionAccessControl.allowedSourceRanges) + && Objects.equals( + this.additionalProperties, + loadbalancerOptionAccessControl.additionalProperties); } @Override public int hashCode() { - return Objects.hash(allowedSourceRanges); + return Objects.hash(allowedSourceRanges, additionalProperties); } @Override @@ -98,6 +146,9 @@ public String toString() { sb.append(" allowedSourceRanges: ") .append(toIndentedString(allowedSourceRanges)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -141,17 +192,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadbalancerOptionAccessControl.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadbalancerOptionAccessControl.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionAccessControl` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("allowedSourceRanges") != null @@ -183,6 +223,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadbalancerOptionAccessControl 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 +255,41 @@ public LoadbalancerOptionAccessControl 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 + LoadbalancerOptionAccessControl 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionLogs.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionLogs.java index e601e69..d98d08b 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionLogs.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionLogs.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; /** Observability logs configuration. */ @javax.annotation.Generated( @@ -85,6 +86,50 @@ public void setPushUrl(@javax.annotation.Nullable String pushUrl) { this.pushUrl = pushUrl; } + /** + * 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 LoadbalancerOptionLogs instance itself + */ + public LoadbalancerOptionLogs 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) { @@ -95,12 +140,14 @@ public boolean equals(Object o) { } LoadbalancerOptionLogs loadbalancerOptionLogs = (LoadbalancerOptionLogs) o; return Objects.equals(this.credentialsRef, loadbalancerOptionLogs.credentialsRef) - && Objects.equals(this.pushUrl, loadbalancerOptionLogs.pushUrl); + && Objects.equals(this.pushUrl, loadbalancerOptionLogs.pushUrl) + && Objects.equals( + this.additionalProperties, loadbalancerOptionLogs.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credentialsRef, pushUrl); + return Objects.hash(credentialsRef, pushUrl, additionalProperties); } @Override @@ -109,6 +156,9 @@ public String toString() { sb.append("class LoadbalancerOptionLogs {\n"); sb.append(" credentialsRef: ").append(toIndentedString(credentialsRef)).append("\n"); sb.append(" pushUrl: ").append(toIndentedString(pushUrl)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -151,17 +201,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadbalancerOptionLogs.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadbalancerOptionLogs.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionLogs` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) && !jsonObj.get("credentialsRef").isJsonPrimitive()) { @@ -196,6 +235,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadbalancerOptionLogs 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); } @@ -203,7 +266,40 @@ public void write(JsonWriter out, LoadbalancerOptionLogs value) public LoadbalancerOptionLogs 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 + LoadbalancerOptionLogs 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionMetrics.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionMetrics.java index c49dd84..c61ce62 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionMetrics.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionMetrics.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; /** Observability metrics configuration. */ @javax.annotation.Generated( @@ -87,6 +88,50 @@ public void setPushUrl(@javax.annotation.Nullable String pushUrl) { this.pushUrl = pushUrl; } + /** + * 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 LoadbalancerOptionMetrics instance itself + */ + public LoadbalancerOptionMetrics 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) { @@ -97,12 +142,14 @@ public boolean equals(Object o) { } LoadbalancerOptionMetrics loadbalancerOptionMetrics = (LoadbalancerOptionMetrics) o; return Objects.equals(this.credentialsRef, loadbalancerOptionMetrics.credentialsRef) - && Objects.equals(this.pushUrl, loadbalancerOptionMetrics.pushUrl); + && Objects.equals(this.pushUrl, loadbalancerOptionMetrics.pushUrl) + && Objects.equals( + this.additionalProperties, loadbalancerOptionMetrics.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credentialsRef, pushUrl); + return Objects.hash(credentialsRef, pushUrl, additionalProperties); } @Override @@ -111,6 +158,9 @@ public String toString() { sb.append("class LoadbalancerOptionMetrics {\n"); sb.append(" credentialsRef: ").append(toIndentedString(credentialsRef)).append("\n"); sb.append(" pushUrl: ").append(toIndentedString(pushUrl)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -153,17 +203,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadbalancerOptionMetrics.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadbalancerOptionMetrics.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionMetrics` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) && !jsonObj.get("credentialsRef").isJsonPrimitive()) { @@ -199,6 +238,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadbalancerOptionMetrics 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); } @@ -206,7 +269,40 @@ public void write(JsonWriter out, LoadbalancerOptionMetrics value) public LoadbalancerOptionMetrics 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 + LoadbalancerOptionMetrics 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/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionObservability.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionObservability.java index 537266a..83948f1 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionObservability.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/LoadbalancerOptionObservability.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; /** We offer Load Balancer observability via STACKIT Observability or external solutions. */ @javax.annotation.Generated( @@ -84,6 +85,50 @@ public void setMetrics(@javax.annotation.Nullable LoadbalancerOptionMetrics metr this.metrics = metrics; } + /** + * 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 LoadbalancerOptionObservability instance itself + */ + public LoadbalancerOptionObservability 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) { @@ -95,12 +140,15 @@ public boolean equals(Object o) { LoadbalancerOptionObservability loadbalancerOptionObservability = (LoadbalancerOptionObservability) o; return Objects.equals(this.logs, loadbalancerOptionObservability.logs) - && Objects.equals(this.metrics, loadbalancerOptionObservability.metrics); + && Objects.equals(this.metrics, loadbalancerOptionObservability.metrics) + && Objects.equals( + this.additionalProperties, + loadbalancerOptionObservability.additionalProperties); } @Override public int hashCode() { - return Objects.hash(logs, metrics); + return Objects.hash(logs, metrics, additionalProperties); } @Override @@ -109,6 +157,9 @@ public String toString() { sb.append("class LoadbalancerOptionObservability {\n"); sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); sb.append(" metrics: ").append(toIndentedString(metrics)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -152,17 +203,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti LoadbalancerOptionObservability.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!LoadbalancerOptionObservability.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionObservability` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `logs` if (jsonObj.get("logs") != null && !jsonObj.get("logs").isJsonNull()) { @@ -193,6 +233,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, LoadbalancerOptionObservability 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); } @@ -201,7 +265,41 @@ public LoadbalancerOptionObservability 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 + LoadbalancerOptionObservability 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Network.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Network.java index 9e93d47..64b65dd 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Network.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Network.java @@ -25,10 +25,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; /** Network */ @@ -145,6 +146,50 @@ public void setRole(@javax.annotation.Nullable RoleEnum role) { this.role = role; } + /** + * 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 Network instance itself + */ + public Network 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) { @@ -155,12 +200,13 @@ public boolean equals(Object o) { } Network network = (Network) o; return Objects.equals(this.networkId, network.networkId) - && Objects.equals(this.role, network.role); + && Objects.equals(this.role, network.role) + && Objects.equals(this.additionalProperties, network.additionalProperties); } @Override public int hashCode() { - return Objects.hash(networkId, role); + return Objects.hash(networkId, role, additionalProperties); } @Override @@ -169,6 +215,9 @@ public String toString() { sb.append("class Network {\n"); sb.append(" networkId: ").append(toIndentedString(networkId)).append("\n"); sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -211,17 +260,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Network.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Network.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Network` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("networkId") != null && !jsonObj.get("networkId").isJsonNull()) && !jsonObj.get("networkId").isJsonPrimitive()) { @@ -259,6 +297,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Network 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); } @@ -266,7 +328,40 @@ public void write(JsonWriter out, Network value) throws IOException { public Network 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 + Network 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Path.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Path.java index af89e4a..0681df0 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Path.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Path.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; /** * Path match. Optional. Contains either an exact or prefix match. If not set, defaults to root path @@ -88,6 +89,50 @@ public void setPrefix(@javax.annotation.Nullable String prefix) { this.prefix = prefix; } + /** + * 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 Path instance itself + */ + public Path 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) { @@ -98,12 +143,13 @@ public boolean equals(Object o) { } Path path = (Path) o; return Objects.equals(this.exactMatch, path.exactMatch) - && Objects.equals(this.prefix, path.prefix); + && Objects.equals(this.prefix, path.prefix) + && Objects.equals(this.additionalProperties, path.additionalProperties); } @Override public int hashCode() { - return Objects.hash(exactMatch, prefix); + return Objects.hash(exactMatch, prefix, additionalProperties); } @Override @@ -112,6 +158,9 @@ public String toString() { sb.append("class Path {\n"); sb.append(" exactMatch: ").append(toIndentedString(exactMatch)).append("\n"); sb.append(" prefix: ").append(toIndentedString(prefix)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -154,17 +203,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Path.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Path.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Path` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("exactMatch") != null && !jsonObj.get("exactMatch").isJsonNull()) && !jsonObj.get("exactMatch").isJsonPrimitive()) { @@ -198,6 +236,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Path 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 +267,40 @@ public void write(JsonWriter out, Path value) throws IOException { public Path 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 + Path 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/alb/src/main/java/cloud/stackit/sdk/alb/model/PlanDetails.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/PlanDetails.java index b9a8ded..4ff812b 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/PlanDetails.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/PlanDetails.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; /** PlanDetails */ @javax.annotation.Generated( @@ -174,6 +175,50 @@ public void setRegion(@javax.annotation.Nullable String region) { this.region = region; } + /** + * 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 PlanDetails instance itself + */ + public PlanDetails 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) { @@ -188,12 +233,20 @@ public boolean equals(Object o) { && Objects.equals(this.maxConnections, planDetails.maxConnections) && Objects.equals(this.name, planDetails.name) && Objects.equals(this.planId, planDetails.planId) - && Objects.equals(this.region, planDetails.region); + && Objects.equals(this.region, planDetails.region) + && Objects.equals(this.additionalProperties, planDetails.additionalProperties); } @Override public int hashCode() { - return Objects.hash(description, flavorName, maxConnections, name, planId, region); + return Objects.hash( + description, + flavorName, + maxConnections, + name, + planId, + region, + additionalProperties); } @Override @@ -206,6 +259,9 @@ public String toString() { sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" planId: ").append(toIndentedString(planId)).append("\n"); sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -256,17 +312,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti PlanDetails.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!PlanDetails.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `PlanDetails` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) { @@ -321,6 +366,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, PlanDetails 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); } @@ -328,7 +397,40 @@ public void write(JsonWriter out, PlanDetails value) throws IOException { public PlanDetails 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 + PlanDetails 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/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTP.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTP.java index 90ea9b1..daec208 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTP.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTP.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; /** Configuration for handling HTTP traffic on this listener. */ @javax.annotation.Generated( @@ -70,6 +70,50 @@ public void setHosts(@javax.annotation.Nullable List hosts) { this.hosts = hosts; } + /** + * 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 ProtocolOptionsHTTP instance itself + */ + public ProtocolOptionsHTTP 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; } ProtocolOptionsHTTP protocolOptionsHTTP = (ProtocolOptionsHTTP) o; - return Objects.equals(this.hosts, protocolOptionsHTTP.hosts); + return Objects.equals(this.hosts, protocolOptionsHTTP.hosts) + && Objects.equals( + this.additionalProperties, protocolOptionsHTTP.additionalProperties); } @Override public int hashCode() { - return Objects.hash(hosts); + return Objects.hash(hosts, additionalProperties); } @Override @@ -92,6 +138,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ProtocolOptionsHTTP {\n"); sb.append(" hosts: ").append(toIndentedString(hosts)).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 ProtocolOptionsHTTP.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProtocolOptionsHTTP.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ProtocolOptionsHTTP` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("hosts") != null && !jsonObj.get("hosts").isJsonNull()) { JsonArray jsonArrayhosts = jsonObj.getAsJsonArray("hosts"); @@ -183,6 +221,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ProtocolOptionsHTTP 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, ProtocolOptionsHTTP value) public ProtocolOptionsHTTP 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 + ProtocolOptionsHTTP 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/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTPS.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTPS.java index f79b148..7ad0117 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTPS.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/ProtocolOptionsHTTPS.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; /** Configuration for handling HTTPS traffic on this listener. */ @javax.annotation.Generated( @@ -61,6 +62,50 @@ public void setCertificateConfig( this.certificateConfig = certificateConfig; } + /** + * 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 ProtocolOptionsHTTPS instance itself + */ + public ProtocolOptionsHTTPS 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) { @@ -70,12 +115,14 @@ public boolean equals(Object o) { return false; } ProtocolOptionsHTTPS protocolOptionsHTTPS = (ProtocolOptionsHTTPS) o; - return Objects.equals(this.certificateConfig, protocolOptionsHTTPS.certificateConfig); + return Objects.equals(this.certificateConfig, protocolOptionsHTTPS.certificateConfig) + && Objects.equals( + this.additionalProperties, protocolOptionsHTTPS.additionalProperties); } @Override public int hashCode() { - return Objects.hash(certificateConfig); + return Objects.hash(certificateConfig, additionalProperties); } @Override @@ -85,6 +132,9 @@ public String toString() { sb.append(" certificateConfig: ") .append(toIndentedString(certificateConfig)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -127,17 +177,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ProtocolOptionsHTTPS.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ProtocolOptionsHTTPS.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ProtocolOptionsHTTPS` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `certificateConfig` if (jsonObj.get("certificateConfig") != null @@ -163,6 +202,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ProtocolOptionsHTTPS 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); } @@ -170,7 +233,40 @@ public void write(JsonWriter out, ProtocolOptionsHTTPS value) public ProtocolOptionsHTTPS 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 + ProtocolOptionsHTTPS 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/alb/src/main/java/cloud/stackit/sdk/alb/model/QueryParameter.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/QueryParameter.java index a8fa767..0721d50 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/QueryParameter.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/QueryParameter.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; /** QueryParameter */ @javax.annotation.Generated( @@ -82,6 +83,50 @@ public void setName(@javax.annotation.Nullable String name) { this.name = name; } + /** + * 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 QueryParameter instance itself + */ + public QueryParameter 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) { @@ -92,12 +137,13 @@ public boolean equals(Object o) { } QueryParameter queryParameter = (QueryParameter) o; return Objects.equals(this.exactMatch, queryParameter.exactMatch) - && Objects.equals(this.name, queryParameter.name); + && Objects.equals(this.name, queryParameter.name) + && Objects.equals(this.additionalProperties, queryParameter.additionalProperties); } @Override public int hashCode() { - return Objects.hash(exactMatch, name); + return Objects.hash(exactMatch, name, additionalProperties); } @Override @@ -106,6 +152,9 @@ public String toString() { sb.append("class QueryParameter {\n"); sb.append(" exactMatch: ").append(toIndentedString(exactMatch)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -148,17 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti QueryParameter.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!QueryParameter.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `QueryParameter` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("exactMatch") != null && !jsonObj.get("exactMatch").isJsonNull()) && !jsonObj.get("exactMatch").isJsonPrimitive()) { @@ -192,6 +230,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, QueryParameter 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); } @@ -199,7 +261,40 @@ public void write(JsonWriter out, QueryParameter value) throws IOException { public QueryParameter 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 + QueryParameter 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Rule.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Rule.java index bfcbbd0..ebe30a3 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Rule.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Rule.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; /** Rule */ @javax.annotation.Generated( @@ -198,6 +198,50 @@ public void setWebSocket(@javax.annotation.Nullable Boolean webSocket) { this.webSocket = webSocket; } + /** + * 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 Rule instance itself + */ + public Rule 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,13 +256,20 @@ public boolean equals(Object o) { && Objects.equals(this.path, rule.path) && Objects.equals(this.queryParameters, rule.queryParameters) && Objects.equals(this.targetPool, rule.targetPool) - && Objects.equals(this.webSocket, rule.webSocket); + && Objects.equals(this.webSocket, rule.webSocket) + && Objects.equals(this.additionalProperties, rule.additionalProperties); } @Override public int hashCode() { return Objects.hash( - cookiePersistence, headers, path, queryParameters, targetPool, webSocket); + cookiePersistence, + headers, + path, + queryParameters, + targetPool, + webSocket, + additionalProperties); } @Override @@ -233,6 +284,9 @@ public String toString() { sb.append(" queryParameters: ").append(toIndentedString(queryParameters)).append("\n"); sb.append(" targetPool: ").append(toIndentedString(targetPool)).append("\n"); sb.append(" webSocket: ").append(toIndentedString(webSocket)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -283,17 +337,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Rule.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Rule.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Rule` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `cookiePersistence` if (jsonObj.get("cookiePersistence") != null @@ -366,6 +409,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Rule 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); } @@ -373,7 +440,40 @@ public void write(JsonWriter out, Rule value) throws IOException { public Rule 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 + Rule 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/alb/src/main/java/cloud/stackit/sdk/alb/model/SecurityGroup.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/SecurityGroup.java index 0174567..d04e675 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/SecurityGroup.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/SecurityGroup.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; /** SecurityGroup */ @javax.annotation.Generated( @@ -82,6 +83,50 @@ public void setName(@javax.annotation.Nullable String name) { this.name = name; } + /** + * 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 SecurityGroup instance itself + */ + public SecurityGroup 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) { @@ -92,12 +137,13 @@ public boolean equals(Object o) { } SecurityGroup securityGroup = (SecurityGroup) o; return Objects.equals(this.id, securityGroup.id) - && Objects.equals(this.name, securityGroup.name); + && Objects.equals(this.name, securityGroup.name) + && Objects.equals(this.additionalProperties, securityGroup.additionalProperties); } @Override public int hashCode() { - return Objects.hash(id, name); + return Objects.hash(id, name, additionalProperties); } @Override @@ -106,6 +152,9 @@ public String toString() { sb.append("class SecurityGroup {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -148,17 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti SecurityGroup.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SecurityGroup.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `SecurityGroup` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { @@ -192,6 +230,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, SecurityGroup 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); } @@ -199,7 +261,40 @@ public void write(JsonWriter out, SecurityGroup value) throws IOException { public SecurityGroup 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 + SecurityGroup 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Status.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Status.java index 0b31916..ecb5107 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Status.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Status.java @@ -25,11 +25,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; /** * The `Status` type defines a logical error model that is suitable for different @@ -124,6 +124,50 @@ public void setMessage(@javax.annotation.Nullable String message) { this.message = message; } + /** + * 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 Status instance itself + */ + public Status 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) { @@ -135,12 +179,13 @@ public boolean equals(Object o) { Status status = (Status) o; return Objects.equals(this.code, status.code) && Objects.equals(this.details, status.details) - && Objects.equals(this.message, status.message); + && Objects.equals(this.message, status.message) + && Objects.equals(this.additionalProperties, status.additionalProperties); } @Override public int hashCode() { - return Objects.hash(code, details, message); + return Objects.hash(code, details, message, additionalProperties); } @Override @@ -150,6 +195,9 @@ public String toString() { sb.append(" code: ").append(toIndentedString(code)).append("\n"); sb.append(" details: ").append(toIndentedString(details)).append("\n"); sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -192,17 +240,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Status.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Status.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Status` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // ensure the optional json data is an array if present if (jsonObj.get("details") != null @@ -238,6 +275,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Status 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); } @@ -245,7 +306,40 @@ public void write(JsonWriter out, Status value) throws IOException { public Status 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 + Status 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/alb/src/main/java/cloud/stackit/sdk/alb/model/Target.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Target.java index 647eef8..0f4dc7c 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Target.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/Target.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; /** Target */ @javax.annotation.Generated( @@ -82,6 +83,50 @@ public void setIp(@javax.annotation.Nullable String ip) { this.ip = ip; } + /** + * 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 Target instance itself + */ + public Target 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) { @@ -92,12 +137,13 @@ public boolean equals(Object o) { } Target target = (Target) o; return Objects.equals(this.displayName, target.displayName) - && Objects.equals(this.ip, target.ip); + && Objects.equals(this.ip, target.ip) + && Objects.equals(this.additionalProperties, target.additionalProperties); } @Override public int hashCode() { - return Objects.hash(displayName, ip); + return Objects.hash(displayName, ip, additionalProperties); } @Override @@ -106,6 +152,9 @@ public String toString() { sb.append("class Target {\n"); sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -148,17 +197,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti Target.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!Target.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `Target` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) { @@ -192,6 +230,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, Target 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); } @@ -199,7 +261,40 @@ public void write(JsonWriter out, Target value) throws IOException { public Target 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 + Target 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/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPool.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPool.java index 8da4c2d..43b81ae 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPool.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPool.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; /** TargetPool */ @javax.annotation.Generated( @@ -165,6 +165,50 @@ public void setTlsConfig(@javax.annotation.Nullable TargetPoolTlsConfig tlsConfi this.tlsConfig = tlsConfig; } + /** + * 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 TargetPool instance itself + */ + public TargetPool 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) { @@ -178,12 +222,14 @@ public boolean equals(Object o) { && Objects.equals(this.name, targetPool.name) && Objects.equals(this.targetPort, targetPool.targetPort) && Objects.equals(this.targets, targetPool.targets) - && Objects.equals(this.tlsConfig, targetPool.tlsConfig); + && Objects.equals(this.tlsConfig, targetPool.tlsConfig) + && Objects.equals(this.additionalProperties, targetPool.additionalProperties); } @Override public int hashCode() { - return Objects.hash(activeHealthCheck, name, targetPort, targets, tlsConfig); + return Objects.hash( + activeHealthCheck, name, targetPort, targets, tlsConfig, additionalProperties); } @Override @@ -197,6 +243,9 @@ public String toString() { sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); sb.append(" tlsConfig: ").append(toIndentedString(tlsConfig)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -242,17 +291,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TargetPool.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TargetPool.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `TargetPool` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `activeHealthCheck` if (jsonObj.get("activeHealthCheck") != null @@ -306,6 +344,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, TargetPool 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); } @@ -313,7 +375,40 @@ public void write(JsonWriter out, TargetPool value) throws IOException { public TargetPool 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 + TargetPool 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/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPoolTlsConfig.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPoolTlsConfig.java index acafbb0..89a5993 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPoolTlsConfig.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/TargetPoolTlsConfig.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; /** TLSConfig used for the target pool. */ @javax.annotation.Generated( @@ -116,6 +117,50 @@ public void setSkipCertificateValidation( this.skipCertificateValidation = skipCertificateValidation; } + /** + * 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 TargetPoolTlsConfig instance itself + */ + public TargetPoolTlsConfig 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) { @@ -129,12 +174,14 @@ public boolean equals(Object o) { && Objects.equals(this.enabled, targetPoolTlsConfig.enabled) && Objects.equals( this.skipCertificateValidation, - targetPoolTlsConfig.skipCertificateValidation); + targetPoolTlsConfig.skipCertificateValidation) + && Objects.equals( + this.additionalProperties, targetPoolTlsConfig.additionalProperties); } @Override public int hashCode() { - return Objects.hash(customCa, enabled, skipCertificateValidation); + return Objects.hash(customCa, enabled, skipCertificateValidation, additionalProperties); } @Override @@ -146,6 +193,9 @@ public String toString() { sb.append(" skipCertificateValidation: ") .append(toIndentedString(skipCertificateValidation)) .append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -190,17 +240,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti TargetPoolTlsConfig.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!TargetPoolTlsConfig.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `TargetPoolTlsConfig` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("customCa") != null && !jsonObj.get("customCa").isJsonNull()) && !jsonObj.get("customCa").isJsonPrimitive()) { @@ -228,6 +267,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, TargetPoolTlsConfig 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); } @@ -235,7 +298,40 @@ public void write(JsonWriter out, TargetPoolTlsConfig value) public TargetPoolTlsConfig 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 + TargetPoolTlsConfig 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/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsPayload.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsPayload.java index 0f8a833..a5ae1e2 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsPayload.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsPayload.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; /** UpdateCredentialsPayload */ @javax.annotation.Generated( @@ -107,6 +108,50 @@ public void setUsername(@javax.annotation.Nullable String username) { this.username = username; } + /** + * 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 UpdateCredentialsPayload instance itself + */ + public UpdateCredentialsPayload 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) { @@ -118,12 +163,14 @@ public boolean equals(Object o) { UpdateCredentialsPayload updateCredentialsPayload = (UpdateCredentialsPayload) o; return Objects.equals(this.displayName, updateCredentialsPayload.displayName) && Objects.equals(this.password, updateCredentialsPayload.password) - && Objects.equals(this.username, updateCredentialsPayload.username); + && Objects.equals(this.username, updateCredentialsPayload.username) + && Objects.equals( + this.additionalProperties, updateCredentialsPayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(displayName, password, username); + return Objects.hash(displayName, password, username, additionalProperties); } @Override @@ -133,6 +180,9 @@ public String toString() { sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); sb.append(" password: ").append(toIndentedString(password)).append("\n"); sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -175,17 +225,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UpdateCredentialsPayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateCredentialsPayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateCredentialsPayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) { @@ -228,6 +267,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateCredentialsPayload 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); } @@ -235,7 +298,40 @@ public void write(JsonWriter out, UpdateCredentialsPayload value) public UpdateCredentialsPayload 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 + UpdateCredentialsPayload 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/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsResponse.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsResponse.java index 5880541..b64ee0c 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsResponse.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateCredentialsResponse.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; /** UpdateCredentialsResponse */ @javax.annotation.Generated( @@ -60,6 +61,50 @@ public void setCredential(@javax.annotation.Nullable CredentialsResponse credent this.credential = credential; } + /** + * 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 UpdateCredentialsResponse instance itself + */ + public UpdateCredentialsResponse 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) { @@ -69,12 +114,14 @@ public boolean equals(Object o) { return false; } UpdateCredentialsResponse updateCredentialsResponse = (UpdateCredentialsResponse) o; - return Objects.equals(this.credential, updateCredentialsResponse.credential); + return Objects.equals(this.credential, updateCredentialsResponse.credential) + && Objects.equals( + this.additionalProperties, updateCredentialsResponse.additionalProperties); } @Override public int hashCode() { - return Objects.hash(credential); + return Objects.hash(credential, additionalProperties); } @Override @@ -82,6 +129,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class UpdateCredentialsResponse {\n"); sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -124,17 +174,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UpdateCredentialsResponse.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateCredentialsResponse.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateCredentialsResponse` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `credential` if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { @@ -160,6 +199,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateCredentialsResponse 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); } @@ -167,7 +230,40 @@ public void write(JsonWriter out, UpdateCredentialsResponse value) public UpdateCredentialsResponse 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 + UpdateCredentialsResponse 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/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateLoadBalancerPayload.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateLoadBalancerPayload.java index 6daf987..d1ecc45 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateLoadBalancerPayload.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateLoadBalancerPayload.java @@ -32,7 +32,6 @@ import java.util.List; import java.util.Map; import java.util.Objects; -import java.util.Set; /** UpdateLoadBalancerPayload */ @javax.annotation.Generated( @@ -495,6 +494,50 @@ public void setVersion(@javax.annotation.Nullable String version) { this.version = version; } + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map 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 UpdateLoadBalancerPayload instance itself + */ + public UpdateLoadBalancerPayload 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) { @@ -524,7 +567,9 @@ public boolean equals(Object o) { && Objects.equals(this.targetPools, updateLoadBalancerPayload.targetPools) && Objects.equals( this.targetSecurityGroup, updateLoadBalancerPayload.targetSecurityGroup) - && Objects.equals(this.version, updateLoadBalancerPayload.version); + && Objects.equals(this.version, updateLoadBalancerPayload.version) + && Objects.equals( + this.additionalProperties, updateLoadBalancerPayload.additionalProperties); } @Override @@ -545,7 +590,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -574,6 +620,9 @@ public String toString() { .append(toIndentedString(targetSecurityGroup)) .append("\n"); sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -634,17 +683,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UpdateLoadBalancerPayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateLoadBalancerPayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateLoadBalancerPayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); @@ -805,6 +843,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateLoadBalancerPayload 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); } @@ -812,7 +874,40 @@ public void write(JsonWriter out, UpdateLoadBalancerPayload value) public UpdateLoadBalancerPayload 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 + UpdateLoadBalancerPayload 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/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateTargetPoolPayload.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateTargetPoolPayload.java index 479866a..ed0ecc1 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateTargetPoolPayload.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/model/UpdateTargetPoolPayload.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; /** UpdateTargetPoolPayload */ @javax.annotation.Generated( @@ -166,6 +166,50 @@ public void setTlsConfig(@javax.annotation.Nullable TargetPoolTlsConfig tlsConfi this.tlsConfig = tlsConfig; } + /** + * 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 UpdateTargetPoolPayload instance itself + */ + public UpdateTargetPoolPayload 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) { @@ -179,12 +223,15 @@ public boolean equals(Object o) { && Objects.equals(this.name, updateTargetPoolPayload.name) && Objects.equals(this.targetPort, updateTargetPoolPayload.targetPort) && Objects.equals(this.targets, updateTargetPoolPayload.targets) - && Objects.equals(this.tlsConfig, updateTargetPoolPayload.tlsConfig); + && Objects.equals(this.tlsConfig, updateTargetPoolPayload.tlsConfig) + && Objects.equals( + this.additionalProperties, updateTargetPoolPayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(activeHealthCheck, name, targetPort, targets, tlsConfig); + return Objects.hash( + activeHealthCheck, name, targetPort, targets, tlsConfig, additionalProperties); } @Override @@ -198,6 +245,9 @@ public String toString() { sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); sb.append(" tlsConfig: ").append(toIndentedString(tlsConfig)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -243,17 +293,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti UpdateTargetPoolPayload.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!UpdateTargetPoolPayload.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `UpdateTargetPoolPayload` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); // validate the optional field `activeHealthCheck` if (jsonObj.get("activeHealthCheck") != null @@ -309,6 +348,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, UpdateTargetPoolPayload 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); } @@ -316,7 +379,40 @@ public void write(JsonWriter out, UpdateTargetPoolPayload value) public UpdateTargetPoolPayload 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 + UpdateTargetPoolPayload 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(); }