diff --git a/services/loadbalancer/oas_commit b/services/loadbalancer/oas_commit new file mode 100644 index 0000000..148a7d9 --- /dev/null +++ b/services/loadbalancer/oas_commit @@ -0,0 +1 @@ +ed4e4fbee2f5db4d95725108fb3d736e5363fb2f diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java index 09c0f6d..bae17e6 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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; /** ActiveHealthCheck */ @javax.annotation.Generated( @@ -152,6 +153,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) { @@ -165,13 +210,20 @@ 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 public int hashCode() { return Objects.hash( - healthyThreshold, interval, intervalJitter, timeout, unhealthyThreshold); + healthyThreshold, + interval, + intervalJitter, + timeout, + unhealthyThreshold, + additionalProperties); } @Override @@ -185,6 +237,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(); } @@ -234,17 +289,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(); if ((jsonObj.get("interval") != null && !jsonObj.get("interval").isJsonNull()) && !jsonObj.get("interval").isJsonPrimitive()) { @@ -286,6 +330,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); } @@ -293,7 +361,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java index bdace12..39109c9 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java index 743a0bd..3ab51d2 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java index d969345..270f263 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -503,6 +502,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 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) { @@ -532,7 +575,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 @@ -553,7 +598,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -582,6 +628,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(); } @@ -642,17 +691,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"); @@ -813,6 +851,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); } @@ -820,7 +882,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java index 243688b..e56d246 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java index d9edadd..531fa9c 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java index ef94563..b4ab410 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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 */ @@ -35,6 +36,11 @@ value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.15.0") public class GetQuotaResponse { + public static final String SERIALIZED_NAME_MAX_CREDENTIALS = "maxCredentials"; + + @SerializedName(SERIALIZED_NAME_MAX_CREDENTIALS) + @javax.annotation.Nullable private Integer maxCredentials; + public static final String SERIALIZED_NAME_MAX_LOAD_BALANCERS = "maxLoadBalancers"; @SerializedName(SERIALIZED_NAME_MAX_LOAD_BALANCERS) @@ -50,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) { @@ -58,6 +74,25 @@ public GetQuotaResponse(UUID projectId, String region) { this.region = region; } + public GetQuotaResponse maxCredentials(@javax.annotation.Nullable Integer maxCredentials) { + this.maxCredentials = maxCredentials; + return this; + } + + /** + * The maximum number of observability credentials that can be stored in this project. minimum: + * -1 maximum: 999 + * + * @return maxCredentials + */ + @javax.annotation.Nullable public Integer getMaxCredentials() { + return maxCredentials; + } + + public void setMaxCredentials(@javax.annotation.Nullable Integer maxCredentials) { + this.maxCredentials = maxCredentials; + } + public GetQuotaResponse maxLoadBalancers(@javax.annotation.Nullable Integer maxLoadBalancers) { this.maxLoadBalancers = maxLoadBalancers; return this; @@ -95,6 +130,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) { @@ -104,23 +222,42 @@ public boolean equals(Object o) { return false; } GetQuotaResponse getQuotaResponse = (GetQuotaResponse) o; - return Objects.equals(this.maxLoadBalancers, getQuotaResponse.maxLoadBalancers) + 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(maxLoadBalancers, projectId, region); + return Objects.hash( + maxCredentials, + maxLoadBalancers, + projectId, + region, + usedCredentials, + usedLoadBalancers, + additionalProperties); } @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class GetQuotaResponse {\n"); + sb.append(" maxCredentials: ").append(toIndentedString(maxCredentials)).append("\n"); 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(); } @@ -142,7 +279,14 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) openapiFields = - new HashSet(Arrays.asList("maxLoadBalancers", "projectId", "region")); + new HashSet( + Arrays.asList( + "maxCredentials", + "maxLoadBalancers", + "projectId", + "region", + "usedCredentials", + "usedLoadBalancers")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -164,17 +308,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()) { @@ -209,6 +342,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); } @@ -216,7 +373,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java index e1d1374..496c900 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java index 4c53bfc..6167a6f 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java index 1719a7e..97ba4b4 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java index 396bc3b..2268636 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java @@ -27,11 +27,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; /** Listener */ @javax.annotation.Generated( @@ -295,6 +295,50 @@ public void setUdp(@javax.annotation.Nullable OptionsUDP udp) { this.udp = udp; } + /** + * 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) { @@ -311,13 +355,22 @@ public boolean equals(Object o) { && Objects.equals(this.serverNameIndicators, listener.serverNameIndicators) && Objects.equals(this.targetPool, listener.targetPool) && Objects.equals(this.tcp, listener.tcp) - && Objects.equals(this.udp, listener.udp); + && Objects.equals(this.udp, listener.udp) + && Objects.equals(this.additionalProperties, listener.additionalProperties); } @Override public int hashCode() { return Objects.hash( - displayName, name, port, protocol, serverNameIndicators, targetPool, tcp, udp); + displayName, + name, + port, + protocol, + serverNameIndicators, + targetPool, + tcp, + udp, + additionalProperties); } @Override @@ -334,6 +387,9 @@ public String toString() { sb.append(" targetPool: ").append(toIndentedString(targetPool)).append("\n"); sb.append(" tcp: ").append(toIndentedString(tcp)).append("\n"); sb.append(" udp: ").append(toIndentedString(udp)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -386,17 +442,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(); if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) { @@ -476,6 +521,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); } @@ -483,7 +552,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java index 890abb9..3a1d838 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -499,6 +498,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 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) { @@ -526,7 +569,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 @@ -547,7 +591,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -576,6 +621,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(); } @@ -636,17 +684,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"); @@ -805,6 +842,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); } @@ -812,7 +873,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java index cd56fc6..cb0e2a2 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -163,6 +164,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) { @@ -173,12 +218,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 @@ -187,6 +234,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(); } @@ -229,17 +279,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()) { @@ -278,6 +317,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); } @@ -285,7 +348,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java index 4c38316..c0bb8d1 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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 load balancer. */ @javax.annotation.Generated( @@ -135,6 +136,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) { @@ -147,12 +192,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 @@ -165,6 +217,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(); } @@ -213,17 +268,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()) { @@ -252,6 +296,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); } @@ -259,7 +327,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java index ee781f9..6a60c91 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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 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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java index e94271d..1d04ffb 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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; /** LoadbalancerOptionLogs */ @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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java index 38a158c..8ce0efc 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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; /** LoadbalancerOptionMetrics */ @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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java index 4ea873e..e7f6b82 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java index 43739d8..a45c0a9 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java index 1b55cff..2cfb9b0 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.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; /** * ProtocolOptionsTCP options to be configured for the PROTOCOL_TCP, PROTOCOL_TCP_PROXY, and @@ -64,6 +65,50 @@ public void setIdleTimeout(@javax.annotation.Nullable String idleTimeout) { this.idleTimeout = idleTimeout; } + /** + * 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 OptionsTCP instance itself + */ + public OptionsTCP 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) { @@ -73,12 +118,13 @@ public boolean equals(Object o) { return false; } OptionsTCP optionsTCP = (OptionsTCP) o; - return Objects.equals(this.idleTimeout, optionsTCP.idleTimeout); + return Objects.equals(this.idleTimeout, optionsTCP.idleTimeout) + && Objects.equals(this.additionalProperties, optionsTCP.additionalProperties); } @Override public int hashCode() { - return Objects.hash(idleTimeout); + return Objects.hash(idleTimeout, additionalProperties); } @Override @@ -86,6 +132,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class OptionsTCP {\n"); sb.append(" idleTimeout: ").append(toIndentedString(idleTimeout)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -128,17 +177,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti OptionsTCP.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OptionsTCP.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `OptionsTCP` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("idleTimeout") != null && !jsonObj.get("idleTimeout").isJsonNull()) && !jsonObj.get("idleTimeout").isJsonPrimitive()) { @@ -165,6 +203,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OptionsTCP 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); } @@ -172,7 +234,40 @@ public void write(JsonWriter out, OptionsTCP value) throws IOException { public OptionsTCP 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 + OptionsTCP 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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java index c2a4d14..2148352 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.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; /** ProtocolOptionsUDP options to be configured for the PROTOCOL_UDP protocol. */ @javax.annotation.Generated( @@ -60,6 +61,50 @@ public void setIdleTimeout(@javax.annotation.Nullable String idleTimeout) { this.idleTimeout = idleTimeout; } + /** + * 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 OptionsUDP instance itself + */ + public OptionsUDP 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,13 @@ public boolean equals(Object o) { return false; } OptionsUDP optionsUDP = (OptionsUDP) o; - return Objects.equals(this.idleTimeout, optionsUDP.idleTimeout); + return Objects.equals(this.idleTimeout, optionsUDP.idleTimeout) + && Objects.equals(this.additionalProperties, optionsUDP.additionalProperties); } @Override public int hashCode() { - return Objects.hash(idleTimeout); + return Objects.hash(idleTimeout, additionalProperties); } @Override @@ -82,6 +128,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class OptionsUDP {\n"); sb.append(" idleTimeout: ").append(toIndentedString(idleTimeout)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -124,17 +173,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti OptionsUDP.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!OptionsUDP.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `OptionsUDP` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("idleTimeout") != null && !jsonObj.get("idleTimeout").isJsonNull()) && !jsonObj.get("idleTimeout").isJsonPrimitive()) { @@ -161,6 +199,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { @Override public void write(JsonWriter out, OptionsUDP 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); } @@ -168,7 +230,40 @@ public void write(JsonWriter out, OptionsUDP value) throws IOException { public OptionsUDP 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 + OptionsUDP 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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java index 5440c59..d5eab83 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java index 5c00119..0155023 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java index b9ccfe1..78e2665 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.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; /** ServerNameIndicator */ @javax.annotation.Generated( @@ -59,6 +60,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 ServerNameIndicator instance itself + */ + public ServerNameIndicator putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + @Override public boolean equals(Object o) { if (this == o) { @@ -68,12 +113,14 @@ public boolean equals(Object o) { return false; } ServerNameIndicator serverNameIndicator = (ServerNameIndicator) o; - return Objects.equals(this.name, serverNameIndicator.name); + return Objects.equals(this.name, serverNameIndicator.name) + && Objects.equals( + this.additionalProperties, serverNameIndicator.additionalProperties); } @Override public int hashCode() { - return Objects.hash(name); + return Objects.hash(name, additionalProperties); } @Override @@ -81,6 +128,9 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("class ServerNameIndicator {\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -123,17 +173,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti ServerNameIndicator.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!ServerNameIndicator.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `ServerNameIndicator` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { @@ -161,6 +200,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, ServerNameIndicator 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); } @@ -168,7 +231,40 @@ public void write(JsonWriter out, ServerNameIndicator value) public ServerNameIndicator 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 + ServerNameIndicator 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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java index 98ffcab..6d75bfc 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.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; /** SessionPersistence */ @javax.annotation.Generated( @@ -61,6 +62,50 @@ public void setUseSourceIpAddress(@javax.annotation.Nullable Boolean useSourceIp this.useSourceIpAddress = useSourceIpAddress; } + /** + * 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 SessionPersistence instance itself + */ + public SessionPersistence 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; } SessionPersistence sessionPersistence = (SessionPersistence) o; - return Objects.equals(this.useSourceIpAddress, sessionPersistence.useSourceIpAddress); + return Objects.equals(this.useSourceIpAddress, sessionPersistence.useSourceIpAddress) + && Objects.equals( + this.additionalProperties, sessionPersistence.additionalProperties); } @Override public int hashCode() { - return Objects.hash(useSourceIpAddress); + return Objects.hash(useSourceIpAddress, additionalProperties); } @Override @@ -85,6 +132,9 @@ public String toString() { sb.append(" useSourceIpAddress: ") .append(toIndentedString(useSourceIpAddress)) .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 SessionPersistence.openapiRequiredFields.toString())); } } - - Set> entries = jsonElement.getAsJsonObject().entrySet(); - // check to see if the JSON string contains additional fields - for (Map.Entry entry : entries) { - if (!SessionPersistence.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException( - String.format( - "The field `%s` in the JSON string is not defined in the `SessionPersistence` properties. JSON: %s", - entry.getKey(), jsonElement.toString())); - } - } JsonObject jsonObj = jsonElement.getAsJsonObject(); } @@ -158,6 +197,30 @@ public TypeAdapter create(Gson gson, TypeToken type) { public void write(JsonWriter out, SessionPersistence 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); } @@ -165,7 +228,40 @@ public void write(JsonWriter out, SessionPersistence value) public SessionPersistence 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 + SessionPersistence 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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java index 98375a9..ae7acd0 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java index 73099eb..4b51fdc 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java index a56a553..4f4a08f 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -167,6 +167,50 @@ public void setTargets(@javax.annotation.Nullable List targets) { this.targets = targets; } + /** + * 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) { @@ -180,12 +224,19 @@ public boolean equals(Object o) { && Objects.equals(this.name, targetPool.name) && Objects.equals(this.sessionPersistence, targetPool.sessionPersistence) && Objects.equals(this.targetPort, targetPool.targetPort) - && Objects.equals(this.targets, targetPool.targets); + && Objects.equals(this.targets, targetPool.targets) + && Objects.equals(this.additionalProperties, targetPool.additionalProperties); } @Override public int hashCode() { - return Objects.hash(activeHealthCheck, name, sessionPersistence, targetPort, targets); + return Objects.hash( + activeHealthCheck, + name, + sessionPersistence, + targetPort, + targets, + additionalProperties); } @Override @@ -201,6 +252,9 @@ public String toString() { .append("\n"); sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -250,17 +304,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 @@ -315,6 +358,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); } @@ -322,7 +389,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java index 6bc8575..6bf20c7 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java index 5a89d3a..43f1543 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java index e1de86f..62d4b0e 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -503,6 +502,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) { @@ -532,7 +575,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 @@ -553,7 +598,8 @@ public int hashCode() { status, targetPools, targetSecurityGroup, - version); + version, + additionalProperties); } @Override @@ -582,6 +628,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(); } @@ -642,17 +691,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"); @@ -813,6 +851,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); } @@ -820,7 +882,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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java index a364bdf..6193411 100644 --- a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/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( @@ -167,6 +167,50 @@ public void setTargets(@javax.annotation.Nullable List targets) { this.targets = targets; } + /** + * 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) { @@ -181,12 +225,20 @@ public boolean equals(Object o) { && Objects.equals( this.sessionPersistence, updateTargetPoolPayload.sessionPersistence) && Objects.equals(this.targetPort, updateTargetPoolPayload.targetPort) - && Objects.equals(this.targets, updateTargetPoolPayload.targets); + && Objects.equals(this.targets, updateTargetPoolPayload.targets) + && Objects.equals( + this.additionalProperties, updateTargetPoolPayload.additionalProperties); } @Override public int hashCode() { - return Objects.hash(activeHealthCheck, name, sessionPersistence, targetPort, targets); + return Objects.hash( + activeHealthCheck, + name, + sessionPersistence, + targetPort, + targets, + additionalProperties); } @Override @@ -202,6 +254,9 @@ public String toString() { .append("\n"); sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); sb.append("}"); return sb.toString(); } @@ -251,17 +306,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 @@ -318,6 +362,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); } @@ -325,7 +393,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(); }