From 16bce559cff33e2f92d01daf70e68cdaf48796fa Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Mon, 3 Aug 2026 16:11:33 +0000 Subject: [PATCH] Generate iaas --- services/iaas/oas_commit | 2 +- .../cloud/stackit/sdk/iaas/v1api/JSON.java | 2 - .../iaas/v1api/model/CreateServerPayload.java | 33 +- .../stackit/sdk/iaas/v1api/model/Server.java | 33 +- .../sdk/iaas/v1api/model/ServerVTPM.java | 297 ------------------ .../cloud/stackit/sdk/iaas/v2api/JSON.java | 2 - .../iaas/v2api/model/CreateServerPayload.java | 33 +- .../stackit/sdk/iaas/v2api/model/Server.java | 33 +- .../sdk/iaas/v2api/model/ServerVTPM.java | 297 ------------------ .../stackit/sdk/iaas/v2beta1api/JSON.java | 2 - .../v2beta1api/model/CreateServerPayload.java | 33 +- .../sdk/iaas/v2beta1api/model/Server.java | 33 +- .../sdk/iaas/v2beta1api/model/ServerVTPM.java | 297 ------------------ 13 files changed, 7 insertions(+), 1090 deletions(-) delete mode 100644 services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/ServerVTPM.java delete mode 100644 services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/ServerVTPM.java delete mode 100644 services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/ServerVTPM.java diff --git a/services/iaas/oas_commit b/services/iaas/oas_commit index 1538b64b..e2b748fd 100644 --- a/services/iaas/oas_commit +++ b/services/iaas/oas_commit @@ -1 +1 @@ -d5bd75f47f4b364fa6f71663efb4ba41ec703ac8 +df436ebd7d2d7d953764d84e9582eed936638f7d diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/JSON.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/JSON.java index b561a217..17b81fd9 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/JSON.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/JSON.java @@ -341,8 +341,6 @@ private static Class getClassByDiscriminator( new cloud.stackit.sdk.iaas.v1api.model.ServerNetwork.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v1api.model.ServerNetworking.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new cloud.stackit.sdk.iaas.v1api.model.ServerVTPM.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v1api.model.ServiceAccountMailListResponse .CustomTypeAdapterFactory()); diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/CreateServerPayload.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/CreateServerPayload.java index 316cc916..f1248325 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/CreateServerPayload.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/CreateServerPayload.java @@ -164,11 +164,6 @@ public class CreateServerPayload { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public CreateServerPayload() {} public CreateServerPayload( @@ -611,24 +606,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public CreateServerPayload vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -707,7 +684,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, createServerPayload.updatedAt) && Arrays.equals(this.userData, createServerPayload.userData) && Objects.equals(this.volumes, createServerPayload.volumes) - && Objects.equals(this.vtpm, createServerPayload.vtpm) && Objects.equals( this.additionalProperties, createServerPayload.additionalProperties); } @@ -740,7 +716,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -777,7 +752,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -828,8 +802,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("machineType", "name")); @@ -1010,10 +983,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/Server.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/Server.java index 30cf203f..925d8eb0 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/Server.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/Server.java @@ -164,11 +164,6 @@ public class Server { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public Server() {} public Server( @@ -607,24 +602,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public Server vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -703,7 +680,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, server.updatedAt) && Arrays.equals(this.userData, server.userData) && Objects.equals(this.volumes, server.volumes) - && Objects.equals(this.vtpm, server.vtpm) && Objects.equals(this.additionalProperties, server.additionalProperties); } @@ -735,7 +711,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -772,7 +747,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -823,8 +797,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("machineType", "name")); @@ -1005,10 +978,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/ServerVTPM.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/ServerVTPM.java deleted file mode 100644 index 9d734dc4..00000000 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v1api/model/ServerVTPM.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * STACKIT IaaS API - * This API is deprecated. It will be retired on 01.03.2027. Please use the STACKIT IaaS API V2 instead. - * - * The version of the OpenAPI document: 1 - * Contact: stackit-iaas@mail.schwarz - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package cloud.stackit.sdk.iaas.v1api.model; - -import cloud.stackit.sdk.iaas.v1api.JSON; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** Configuration for the Virtual Trusted Platform Module (vTPM). */ -@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") -public class ServerVTPM { - public static final String SERIALIZED_NAME_ENABLED = "enabled"; - - @SerializedName(SERIALIZED_NAME_ENABLED) - @javax.annotation.Nonnull - private Boolean enabled = false; - - public ServerVTPM() {} - - public ServerVTPM enabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Defines whether the server instance has the Virtual Trusted Platform Module (vTPM) enabled. - * - * @return enabled - */ - @javax.annotation.Nonnull - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - } - - /** - * A container for additional, undeclared properties. This is a holder for any undeclared - * properties as specified with the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. If the property - * does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ServerVTPM instance itself - */ - public ServerVTPM 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) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ServerVTPM serverVTPM = (ServerVTPM) o; - return Objects.equals(this.enabled, serverVTPM.enabled) - && Objects.equals(this.additionalProperties, serverVTPM.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(enabled, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ServerVTPM {\n"); - sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first - * line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("enabled")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("enabled")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ServerVTPM - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ServerVTPM.openapiRequiredFields - .isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field(s) %s in ServerVTPM is not found in the empty JSON string", - ServerVTPM.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ServerVTPM.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field `%s` is not found in the JSON string: %s", - requiredField, - jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ServerVTPM.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ServerVTPM' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = - gson.getDelegateAdapter(this, TypeToken.get(ServerVTPM.class)); - - return (TypeAdapter) - new TypeAdapter() { - @Override - public void write(JsonWriter out, ServerVTPM 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); - } - - @Override - public ServerVTPM read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ServerVTPM 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( - java.util.Locale.ROOT, - "The field `%s` has unknown primitive type. Value: %s", - entry.getKey(), - entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - }.nullSafe(); - } - } - - /** - * Create an instance of ServerVTPM given an JSON string - * - * @param jsonString JSON string - * @return An instance of ServerVTPM - * @throws IOException if the JSON string is invalid with respect to ServerVTPM - */ - public static ServerVTPM fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ServerVTPM.class); - } - - /** - * Convert an instance of ServerVTPM to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/JSON.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/JSON.java index abc11672..e5b97e64 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/JSON.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/JSON.java @@ -454,8 +454,6 @@ private static Class getClassByDiscriminator( new cloud.stackit.sdk.iaas.v2api.model.ServerNetwork.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v2api.model.ServerNetworking.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new cloud.stackit.sdk.iaas.v2api.model.ServerVTPM.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v2api.model.ServiceAccountMailListResponse .CustomTypeAdapterFactory()); diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/CreateServerPayload.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/CreateServerPayload.java index b31a5496..ea6b1dba 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/CreateServerPayload.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/CreateServerPayload.java @@ -165,11 +165,6 @@ public class CreateServerPayload { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public CreateServerPayload() {} public CreateServerPayload( @@ -614,24 +609,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public CreateServerPayload vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -710,7 +687,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, createServerPayload.updatedAt) && Arrays.equals(this.userData, createServerPayload.userData) && Objects.equals(this.volumes, createServerPayload.volumes) - && Objects.equals(this.vtpm, createServerPayload.vtpm) && Objects.equals( this.additionalProperties, createServerPayload.additionalProperties); } @@ -743,7 +719,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -780,7 +755,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -831,8 +805,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = @@ -1012,10 +985,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/Server.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/Server.java index 5cb6efe1..a09bf7f8 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/Server.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/Server.java @@ -164,11 +164,6 @@ public class Server { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public Server() {} public Server( @@ -607,24 +602,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public Server vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -703,7 +680,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, server.updatedAt) && Arrays.equals(this.userData, server.userData) && Objects.equals(this.volumes, server.volumes) - && Objects.equals(this.vtpm, server.vtpm) && Objects.equals(this.additionalProperties, server.additionalProperties); } @@ -735,7 +711,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -772,7 +747,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -823,8 +797,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("machineType", "name")); @@ -1005,10 +978,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/ServerVTPM.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/ServerVTPM.java deleted file mode 100644 index 3651145d..00000000 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2api/model/ServerVTPM.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * STACKIT IaaS API - * This API allows you to create and modify IaaS resources. - * - * The version of the OpenAPI document: 2 - * Contact: stackit-iaas@mail.schwarz - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package cloud.stackit.sdk.iaas.v2api.model; - -import cloud.stackit.sdk.iaas.v2api.JSON; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** Configuration for the Virtual Trusted Platform Module (vTPM). */ -@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") -public class ServerVTPM { - public static final String SERIALIZED_NAME_ENABLED = "enabled"; - - @SerializedName(SERIALIZED_NAME_ENABLED) - @javax.annotation.Nonnull - private Boolean enabled = false; - - public ServerVTPM() {} - - public ServerVTPM enabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Defines whether the server instance has the Virtual Trusted Platform Module (vTPM) enabled. - * - * @return enabled - */ - @javax.annotation.Nonnull - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - } - - /** - * A container for additional, undeclared properties. This is a holder for any undeclared - * properties as specified with the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. If the property - * does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ServerVTPM instance itself - */ - public ServerVTPM 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) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ServerVTPM serverVTPM = (ServerVTPM) o; - return Objects.equals(this.enabled, serverVTPM.enabled) - && Objects.equals(this.additionalProperties, serverVTPM.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(enabled, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ServerVTPM {\n"); - sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first - * line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("enabled")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("enabled")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ServerVTPM - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ServerVTPM.openapiRequiredFields - .isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field(s) %s in ServerVTPM is not found in the empty JSON string", - ServerVTPM.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ServerVTPM.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field `%s` is not found in the JSON string: %s", - requiredField, - jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ServerVTPM.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ServerVTPM' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = - gson.getDelegateAdapter(this, TypeToken.get(ServerVTPM.class)); - - return (TypeAdapter) - new TypeAdapter() { - @Override - public void write(JsonWriter out, ServerVTPM 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); - } - - @Override - public ServerVTPM read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ServerVTPM 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( - java.util.Locale.ROOT, - "The field `%s` has unknown primitive type. Value: %s", - entry.getKey(), - entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - }.nullSafe(); - } - } - - /** - * Create an instance of ServerVTPM given an JSON string - * - * @param jsonString JSON string - * @return An instance of ServerVTPM - * @throws IOException if the JSON string is invalid with respect to ServerVTPM - */ - public static ServerVTPM fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ServerVTPM.class); - } - - /** - * Convert an instance of ServerVTPM to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -} diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/JSON.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/JSON.java index ecdd2847..6edbb0c8 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/JSON.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/JSON.java @@ -468,8 +468,6 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v2beta1api.model.ServerNetworking .CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new cloud.stackit.sdk.iaas.v2beta1api.model.ServerVTPM.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.iaas.v2beta1api.model.ServiceAccountMailListResponse .CustomTypeAdapterFactory()); diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/CreateServerPayload.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/CreateServerPayload.java index b0a03dff..14ecb06b 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/CreateServerPayload.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/CreateServerPayload.java @@ -165,11 +165,6 @@ public class CreateServerPayload { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public CreateServerPayload() {} public CreateServerPayload( @@ -614,24 +609,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public CreateServerPayload vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -710,7 +687,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, createServerPayload.updatedAt) && Arrays.equals(this.userData, createServerPayload.userData) && Objects.equals(this.volumes, createServerPayload.volumes) - && Objects.equals(this.vtpm, createServerPayload.vtpm) && Objects.equals( this.additionalProperties, createServerPayload.additionalProperties); } @@ -743,7 +719,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -780,7 +755,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -831,8 +805,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = @@ -1012,10 +985,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/Server.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/Server.java index 49cb1e5d..fde65946 100644 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/Server.java +++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/Server.java @@ -164,11 +164,6 @@ public class Server { @SerializedName(SERIALIZED_NAME_VOLUMES) @javax.annotation.Nullable private List volumes; - public static final String SERIALIZED_NAME_VTPM = "vtpm"; - - @SerializedName(SERIALIZED_NAME_VTPM) - @javax.annotation.Nullable private ServerVTPM vtpm; - public Server() {} public Server( @@ -607,24 +602,6 @@ public void setVolumes(@javax.annotation.Nullable List volumes) { this.volumes = volumes; } - public Server vtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - return this; - } - - /** - * Get vtpm - * - * @return vtpm - */ - @javax.annotation.Nullable public ServerVTPM getVtpm() { - return vtpm; - } - - public void setVtpm(@javax.annotation.Nullable ServerVTPM vtpm) { - this.vtpm = vtpm; - } - /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -703,7 +680,6 @@ public boolean equals(Object o) { && Objects.equals(this.updatedAt, server.updatedAt) && Arrays.equals(this.userData, server.userData) && Objects.equals(this.volumes, server.volumes) - && Objects.equals(this.vtpm, server.vtpm) && Objects.equals(this.additionalProperties, server.additionalProperties); } @@ -735,7 +711,6 @@ public int hashCode() { updatedAt, Arrays.hashCode(userData), volumes, - vtpm, additionalProperties); } @@ -772,7 +747,6 @@ public String toString() { sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n"); sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); sb.append(" volumes: ").append(toIndentedString(volumes)).append("\n"); - sb.append(" vtpm: ").append(toIndentedString(vtpm)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -823,8 +797,7 @@ private String toIndentedString(Object o) { "status", "updatedAt", "userData", - "volumes", - "vtpm")); + "volumes")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(Arrays.asList("machineType", "name")); @@ -1005,10 +978,6 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `volumes` to be an array in the JSON string but got `%s`", jsonObj.get("volumes").toString())); } - // validate the optional field `vtpm` - if (jsonObj.get("vtpm") != null && !jsonObj.get("vtpm").isJsonNull()) { - ServerVTPM.validateJsonElement(jsonObj.get("vtpm")); - } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/ServerVTPM.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/ServerVTPM.java deleted file mode 100644 index 26e8d243..00000000 --- a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/v2beta1api/model/ServerVTPM.java +++ /dev/null @@ -1,297 +0,0 @@ -/* - * STACKIT IaaS API - * This API allows you to create and modify IaaS resources. - * - * The version of the OpenAPI document: 2beta1 - * Contact: stackit-iaas@mail.schwarz - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ - -package cloud.stackit.sdk.iaas.v2beta1api.model; - -import cloud.stackit.sdk.iaas.v2beta1api.JSON; -import com.google.gson.Gson; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; -import com.google.gson.TypeAdapterFactory; -import com.google.gson.annotations.SerializedName; -import com.google.gson.reflect.TypeToken; -import com.google.gson.stream.JsonReader; -import com.google.gson.stream.JsonWriter; -import java.io.IOException; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Objects; - -/** Configuration for the Virtual Trusted Platform Module (vTPM). */ -@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") -public class ServerVTPM { - public static final String SERIALIZED_NAME_ENABLED = "enabled"; - - @SerializedName(SERIALIZED_NAME_ENABLED) - @javax.annotation.Nonnull - private Boolean enabled = false; - - public ServerVTPM() {} - - public ServerVTPM enabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - return this; - } - - /** - * Defines whether the server instance has the Virtual Trusted Platform Module (vTPM) enabled. - * - * @return enabled - */ - @javax.annotation.Nonnull - public Boolean getEnabled() { - return enabled; - } - - public void setEnabled(@javax.annotation.Nonnull Boolean enabled) { - this.enabled = enabled; - } - - /** - * A container for additional, undeclared properties. This is a holder for any undeclared - * properties as specified with the 'additionalProperties' keyword in the OAS document. - */ - private Map additionalProperties; - - /** - * Set the additional (undeclared) property with the specified name and value. If the property - * does not already exist, create it otherwise replace it. - * - * @param key name of the property - * @param value value of the property - * @return the ServerVTPM instance itself - */ - public ServerVTPM 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) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ServerVTPM serverVTPM = (ServerVTPM) o; - return Objects.equals(this.enabled, serverVTPM.enabled) - && Objects.equals(this.additionalProperties, serverVTPM.additionalProperties); - } - - @Override - public int hashCode() { - return Objects.hash(enabled, additionalProperties); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ServerVTPM {\n"); - sb.append(" enabled: ").append(toIndentedString(enabled)).append("\n"); - sb.append(" additionalProperties: ") - .append(toIndentedString(additionalProperties)) - .append("\n"); - sb.append("}"); - return sb.toString(); - } - - /** - * Convert the given object to string with each line indented by 4 spaces (except the first - * line). - */ - private String toIndentedString(Object o) { - if (o == null) { - return "null"; - } - return o.toString().replace("\n", "\n "); - } - - public static HashSet openapiFields; - public static HashSet openapiRequiredFields; - - static { - // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("enabled")); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(Arrays.asList("enabled")); - } - - /** - * Validates the JSON Element and throws an exception if issues found - * - * @param jsonElement JSON Element - * @throws IOException if the JSON Element is invalid with respect to ServerVTPM - */ - public static void validateJsonElement(JsonElement jsonElement) throws IOException { - if (jsonElement == null) { - if (!ServerVTPM.openapiRequiredFields - .isEmpty()) { // has required fields but JSON element is null - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field(s) %s in ServerVTPM is not found in the empty JSON string", - ServerVTPM.openapiRequiredFields.toString())); - } - } - - // check to make sure all required properties/fields are present in the JSON string - for (String requiredField : ServerVTPM.openapiRequiredFields) { - if (jsonElement.getAsJsonObject().get(requiredField) == null) { - throw new IllegalArgumentException( - String.format( - java.util.Locale.ROOT, - "The required field `%s` is not found in the JSON string: %s", - requiredField, - jsonElement.toString())); - } - } - JsonObject jsonObj = jsonElement.getAsJsonObject(); - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!ServerVTPM.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ServerVTPM' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = - gson.getDelegateAdapter(this, TypeToken.get(ServerVTPM.class)); - - return (TypeAdapter) - new TypeAdapter() { - @Override - public void write(JsonWriter out, ServerVTPM 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); - } - - @Override - public ServerVTPM read(JsonReader in) throws IOException { - JsonElement jsonElement = elementAdapter.read(in); - validateJsonElement(jsonElement); - JsonObject jsonObj = jsonElement.getAsJsonObject(); - // store additional fields in the deserialized instance - ServerVTPM 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( - java.util.Locale.ROOT, - "The field `%s` has unknown primitive type. Value: %s", - entry.getKey(), - entry.getValue().toString())); - } else if (entry.getValue().isJsonArray()) { - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), List.class)); - } else { // JSON object - instance.putAdditionalProperty( - entry.getKey(), - gson.fromJson(entry.getValue(), HashMap.class)); - } - } - } - return instance; - } - }.nullSafe(); - } - } - - /** - * Create an instance of ServerVTPM given an JSON string - * - * @param jsonString JSON string - * @return An instance of ServerVTPM - * @throws IOException if the JSON string is invalid with respect to ServerVTPM - */ - public static ServerVTPM fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ServerVTPM.class); - } - - /** - * Convert an instance of ServerVTPM to an JSON string - * - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } -}