diff --git a/services/sfs/oas_commit b/services/sfs/oas_commit index f1d301ef..8cb892d1 100644 --- a/services/sfs/oas_commit +++ b/services/sfs/oas_commit @@ -1 +1 @@ -0c4c4c22a2db77c6bcc0e27e513531d1c25d4fe1 +51f3e27fb4d3b4da80540f63785240e15e9168ca diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java index c3e28c35..9edec1a4 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/JSON.java @@ -95,6 +95,8 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.v1api.model.ConflictError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.sfs.v1api.model.CreateResourcePoolPayload .CustomTypeAdapterFactory()); diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/api/DefaultApi.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/api/DefaultApi.java index 281d58a6..65529bfd 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/api/DefaultApi.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/api/DefaultApi.java @@ -151,6 +151,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -265,6 +266,7 @@ private okhttp3.Call createResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -294,6 +296,7 @@ public CreateResourcePoolResponse createResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -326,6 +329,7 @@ public ApiResponse createResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -361,6 +365,7 @@ public okhttp3.Call createResourcePoolAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -490,6 +495,7 @@ private okhttp3.Call createResourcePoolSnapshotValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -523,6 +529,7 @@ public CreateResourcePoolSnapshotResponse createResourcePoolSnapshot( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -559,6 +566,7 @@ public ApiResponse createResourcePoolSnapsho * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -600,6 +608,7 @@ public okhttp3.Call createResourcePoolSnapshotAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -726,6 +735,7 @@ private okhttp3.Call createShareValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -757,6 +767,7 @@ public CreateShareResponse createShare( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -791,6 +802,7 @@ public ApiResponse createShareWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -826,6 +838,7 @@ public okhttp3.Call createShareAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -941,6 +954,7 @@ private okhttp3.Call createShareExportPolicyValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -971,6 +985,7 @@ public CreateShareExportPolicyResponse createShareExportPolicy( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1004,6 +1019,7 @@ public ApiResponse createShareExportPolicyWithH * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1038,6 +1054,7 @@ public okhttp3.Call createShareExportPolicyAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1155,6 +1172,7 @@ private okhttp3.Call deleteResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1184,6 +1202,7 @@ public Object deleteResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1215,6 +1234,7 @@ public ApiResponse deleteResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1249,6 +1269,7 @@ public okhttp3.Call deleteResourcePoolAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1379,6 +1400,7 @@ private okhttp3.Call deleteResourcePoolSnapshotValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1411,6 +1433,7 @@ public Object deleteResourcePoolSnapshot( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1446,6 +1469,7 @@ public ApiResponse deleteResourcePoolSnapshotWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1918,6 +1942,7 @@ public okhttp3.Call deleteShareExportPolicyAsync( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -1957,7 +1982,7 @@ public okhttp3.Call disableLockCall( Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); - final String[] localVarAccepts = {"application/json"}; + final String[] localVarAccepts = {"application/json", "application/problem+json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); @@ -2019,6 +2044,7 @@ private okhttp3.Call disableLockValidateBeforeCall( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2042,6 +2068,7 @@ public Object disableLock( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2067,6 +2094,7 @@ public ApiResponse disableLockWithHttpInfo( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2095,6 +2123,7 @@ public okhttp3.Call disableLockAsync( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2134,7 +2163,7 @@ public okhttp3.Call enableLockCall( Map localVarCookieParams = new HashMap(); Map localVarFormParams = new HashMap(); - final String[] localVarAccepts = {"application/json"}; + final String[] localVarAccepts = {"application/json", "application/problem+json"}; final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); if (localVarAccept != null) { localVarHeaderParams.put("Accept", localVarAccept); @@ -2197,6 +2226,7 @@ private okhttp3.Call enableLockValidateBeforeCall( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2221,6 +2251,7 @@ public EnableLockResponse enableLock( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -2247,6 +2278,7 @@ public ApiResponse enableLockWithHttpInfo( * Response Details * Status Code Description Response Headers * 200 OK - + * 409 The request conflicts with the current state of the resource. - * 0 Default error response - * */ @@ -4997,6 +5029,7 @@ public okhttp3.Call listSnapshotPoliciesAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -5124,6 +5157,7 @@ private okhttp3.Call updateResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -5156,6 +5190,7 @@ public UpdateResourcePoolResponse updateResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -5190,6 +5225,7 @@ public ApiResponse updateResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ConflictError.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ConflictError.java new file mode 100644 index 00000000..9251aa30 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ConflictError.java @@ -0,0 +1,404 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * 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.sfs.v1api.model; + +import cloud.stackit.sdk.sfs.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; + +/** Conflict error response */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ConflictError { + public static final String SERIALIZED_NAME_DETAIL = "detail"; + + @SerializedName(SERIALIZED_NAME_DETAIL) + @javax.annotation.Nonnull + private String detail; + + public static final String SERIALIZED_NAME_ERROR_DESCRIPTION = "error_description"; + + @SerializedName(SERIALIZED_NAME_ERROR_DESCRIPTION) + @javax.annotation.Nonnull + private String errorDescription; + + public static final String SERIALIZED_NAME_STATUS_CODE = "status_code"; + + @SerializedName(SERIALIZED_NAME_STATUS_CODE) + @javax.annotation.Nonnull + private Integer statusCode; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public ConflictError() {} + + public ConflictError detail(@javax.annotation.Nonnull String detail) { + this.detail = detail; + return this; + } + + /** + * Human-readable explanation of the specific problem + * + * @return detail + */ + @javax.annotation.Nonnull + public String getDetail() { + return detail; + } + + public void setDetail(@javax.annotation.Nonnull String detail) { + this.detail = detail; + } + + public ConflictError errorDescription(@javax.annotation.Nonnull String errorDescription) { + this.errorDescription = errorDescription; + return this; + } + + /** + * Human-readable string of the error that occurred + * + * @return errorDescription + */ + @javax.annotation.Nonnull + public String getErrorDescription() { + return errorDescription; + } + + public void setErrorDescription(@javax.annotation.Nonnull String errorDescription) { + this.errorDescription = errorDescription; + } + + public ConflictError statusCode(@javax.annotation.Nonnull Integer statusCode) { + this.statusCode = statusCode; + return this; + } + + /** + * The HTTP status code + * + * @return statusCode + */ + @javax.annotation.Nonnull + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(@javax.annotation.Nonnull Integer statusCode) { + this.statusCode = statusCode; + } + + public ConflictError type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * URI Uniquely identifies the error type. It will be in the format of + * storage.stackit.cloud/<error-type> e.g. storage.stackit.cloud/conflict + * + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String 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 ConflictError instance itself + */ + public ConflictError 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; + } + ConflictError conflictError = (ConflictError) o; + return Objects.equals(this.detail, conflictError.detail) + && Objects.equals(this.errorDescription, conflictError.errorDescription) + && Objects.equals(this.statusCode, conflictError.statusCode) + && Objects.equals(this.type, conflictError.type) + && Objects.equals(this.additionalProperties, conflictError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(detail, errorDescription, statusCode, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConflictError {\n"); + sb.append(" detail: ").append(toIndentedString(detail)).append("\n"); + sb.append(" errorDescription: ").append(toIndentedString(errorDescription)).append("\n"); + sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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("detail", "error_description", "status_code", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList("detail", "error_description", "status_code", "type")); + } + + /** + * 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 ConflictError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConflictError.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 ConflictError is not found in the empty JSON string", + ConflictError.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConflictError.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(); + if (!jsonObj.get("detail").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `detail` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("detail").toString())); + } + if (!jsonObj.get("error_description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `error_description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("error_description").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConflictError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConflictError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ConflictError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ConflictError 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 ConflictError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConflictError 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 ConflictError given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConflictError + * @throws IOException if the JSON string is invalid with respect to ConflictError + */ + public static ConflictError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConflictError.class); + } + + /** + * Convert an instance of ConflictError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateResourcePoolPayload.java index 58ffae9d..bc88b3ba 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateResourcePoolPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateResourcePoolPayload.java @@ -144,9 +144,7 @@ public CreateResourcePoolPayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the resource pool keys are - * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot - * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the resource pool. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateShareExportPolicyPayload.java index 9acc21a7..9dfa8e4d 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateShareExportPolicyPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateShareExportPolicyPayload.java @@ -68,10 +68,7 @@ public CreateShareExportPolicyPayload putLabelsItem(String key, String labelsIte } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateSharePayload.java index d92ae778..41c2544f 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateSharePayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/CreateSharePayload.java @@ -93,9 +93,7 @@ public CreateSharePayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/Share.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/Share.java index 891f8fb7..d7691562 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/Share.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/Share.java @@ -148,9 +148,7 @@ public Share putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ShareExportPolicy.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ShareExportPolicy.java index bc513c3a..83b364e4 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ShareExportPolicy.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/ShareExportPolicy.java @@ -119,10 +119,7 @@ public ShareExportPolicy putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateResourcePoolPayload.java index 82fa0e9e..a4557779 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateResourcePoolPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateResourcePoolPayload.java @@ -109,9 +109,7 @@ public UpdateResourcePoolPayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the resource pool keys are - * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot - * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the resource pool. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateShareExportPolicyPayload.java index d910cde9..f82a0af8 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateShareExportPolicyPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateShareExportPolicyPayload.java @@ -63,10 +63,7 @@ public UpdateShareExportPolicyPayload putLabelsItem(String key, String labelsIte } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateSharePayload.java index 15b005c6..1a6c3eb7 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateSharePayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1api/model/UpdateSharePayload.java @@ -87,9 +87,7 @@ public UpdateSharePayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/JSON.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/JSON.java index edeb21da..6e3aba99 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/JSON.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/JSON.java @@ -95,6 +95,8 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.v1betaapi.model.ConflictError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.sfs.v1betaapi.model.CreateResourcePoolPayload .CustomTypeAdapterFactory()); diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/api/DefaultApi.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/api/DefaultApi.java index 35449a30..c690a8e7 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/api/DefaultApi.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/api/DefaultApi.java @@ -144,6 +144,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -258,6 +259,7 @@ private okhttp3.Call createResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -287,6 +289,7 @@ public CreateResourcePoolResponse createResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -319,6 +322,7 @@ public ApiResponse createResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -354,6 +358,7 @@ public okhttp3.Call createResourcePoolAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -483,6 +488,7 @@ private okhttp3.Call createResourcePoolSnapshotValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -516,6 +522,7 @@ public CreateResourcePoolSnapshotResponse createResourcePoolSnapshot( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -552,6 +559,7 @@ public ApiResponse createResourcePoolSnapsho * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -593,6 +601,7 @@ public okhttp3.Call createResourcePoolSnapshotAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -719,6 +728,7 @@ private okhttp3.Call createShareValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -750,6 +760,7 @@ public CreateShareResponse createShare( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -784,6 +795,7 @@ public ApiResponse createShareWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -819,6 +831,7 @@ public okhttp3.Call createShareAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -934,6 +947,7 @@ private okhttp3.Call createShareExportPolicyValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -964,6 +978,7 @@ public CreateShareExportPolicyResponse createShareExportPolicy( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -997,6 +1012,7 @@ public ApiResponse createShareExportPolicyWithH * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1031,6 +1047,7 @@ public okhttp3.Call createShareExportPolicyAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1148,6 +1165,7 @@ private okhttp3.Call deleteResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1177,6 +1195,7 @@ public Object deleteResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1208,6 +1227,7 @@ public ApiResponse deleteResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1242,6 +1262,7 @@ public okhttp3.Call deleteResourcePoolAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1372,6 +1393,7 @@ private okhttp3.Call deleteResourcePoolSnapshotValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1404,6 +1426,7 @@ public Object deleteResourcePoolSnapshot( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -1439,6 +1462,7 @@ public ApiResponse deleteResourcePoolSnapshotWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -3917,6 +3941,7 @@ public okhttp3.Call listSnapshotSchedulesAsync( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -4044,6 +4069,7 @@ private okhttp3.Call updateResourcePoolValidateBeforeCall( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -4076,6 +4102,7 @@ public UpdateResourcePoolResponse updateResourcePool( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ @@ -4110,6 +4137,7 @@ public ApiResponse updateResourcePoolWithHttpInfo( * 200 OK - * 400 Some fields of the request have failed the validation procedure. - * 401 Please make sure the Authorization Header is set and uses correct credentials - + * 409 The request conflicts with the current state of the resource. - * 500 Please retry again later or contact support if the issue persists - * */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ConflictError.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ConflictError.java new file mode 100644 index 00000000..4e045797 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ConflictError.java @@ -0,0 +1,404 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * 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.sfs.v1betaapi.model; + +import cloud.stackit.sdk.sfs.v1betaapi.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; + +/** Conflict error response */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ConflictError { + public static final String SERIALIZED_NAME_DETAIL = "detail"; + + @SerializedName(SERIALIZED_NAME_DETAIL) + @javax.annotation.Nonnull + private String detail; + + public static final String SERIALIZED_NAME_ERROR_DESCRIPTION = "error_description"; + + @SerializedName(SERIALIZED_NAME_ERROR_DESCRIPTION) + @javax.annotation.Nonnull + private String errorDescription; + + public static final String SERIALIZED_NAME_STATUS_CODE = "status_code"; + + @SerializedName(SERIALIZED_NAME_STATUS_CODE) + @javax.annotation.Nonnull + private Integer statusCode; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public ConflictError() {} + + public ConflictError detail(@javax.annotation.Nonnull String detail) { + this.detail = detail; + return this; + } + + /** + * Human-readable explanation of the specific problem + * + * @return detail + */ + @javax.annotation.Nonnull + public String getDetail() { + return detail; + } + + public void setDetail(@javax.annotation.Nonnull String detail) { + this.detail = detail; + } + + public ConflictError errorDescription(@javax.annotation.Nonnull String errorDescription) { + this.errorDescription = errorDescription; + return this; + } + + /** + * Human-readable string of the error that occurred + * + * @return errorDescription + */ + @javax.annotation.Nonnull + public String getErrorDescription() { + return errorDescription; + } + + public void setErrorDescription(@javax.annotation.Nonnull String errorDescription) { + this.errorDescription = errorDescription; + } + + public ConflictError statusCode(@javax.annotation.Nonnull Integer statusCode) { + this.statusCode = statusCode; + return this; + } + + /** + * The HTTP status code + * + * @return statusCode + */ + @javax.annotation.Nonnull + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(@javax.annotation.Nonnull Integer statusCode) { + this.statusCode = statusCode; + } + + public ConflictError type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * URI Uniquely identifies the error type. It will be in the format of + * storage.stackit.cloud/<error-type> e.g. storage.stackit.cloud/conflict + * + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String 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 ConflictError instance itself + */ + public ConflictError 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; + } + ConflictError conflictError = (ConflictError) o; + return Objects.equals(this.detail, conflictError.detail) + && Objects.equals(this.errorDescription, conflictError.errorDescription) + && Objects.equals(this.statusCode, conflictError.statusCode) + && Objects.equals(this.type, conflictError.type) + && Objects.equals(this.additionalProperties, conflictError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(detail, errorDescription, statusCode, type, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ConflictError {\n"); + sb.append(" detail: ").append(toIndentedString(detail)).append("\n"); + sb.append(" errorDescription: ").append(toIndentedString(errorDescription)).append("\n"); + sb.append(" statusCode: ").append(toIndentedString(statusCode)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).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("detail", "error_description", "status_code", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList("detail", "error_description", "status_code", "type")); + } + + /** + * 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 ConflictError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ConflictError.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 ConflictError is not found in the empty JSON string", + ConflictError.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ConflictError.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(); + if (!jsonObj.get("detail").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `detail` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("detail").toString())); + } + if (!jsonObj.get("error_description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `error_description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("error_description").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ConflictError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ConflictError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ConflictError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ConflictError 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 ConflictError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ConflictError 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 ConflictError given an JSON string + * + * @param jsonString JSON string + * @return An instance of ConflictError + * @throws IOException if the JSON string is invalid with respect to ConflictError + */ + public static ConflictError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ConflictError.class); + } + + /** + * Convert an instance of ConflictError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateResourcePoolPayload.java index 46692a78..3e1c4b3c 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateResourcePoolPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateResourcePoolPayload.java @@ -137,9 +137,7 @@ public CreateResourcePoolPayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the resource pool keys are - * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot - * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the resource pool. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateShareExportPolicyPayload.java index b3522dfb..f4825b28 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateShareExportPolicyPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateShareExportPolicyPayload.java @@ -67,10 +67,7 @@ public CreateShareExportPolicyPayload putLabelsItem(String key, String labelsIte } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateSharePayload.java index 9994735d..2ec1e0d1 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateSharePayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/CreateSharePayload.java @@ -91,9 +91,7 @@ public CreateSharePayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/Share.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/Share.java index 05b2dc16..596bd10f 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/Share.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/Share.java @@ -148,9 +148,7 @@ public Share putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ShareExportPolicy.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ShareExportPolicy.java index e255f60c..132692fb 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ShareExportPolicy.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/ShareExportPolicy.java @@ -119,10 +119,7 @@ public ShareExportPolicy putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateResourcePoolPayload.java index ba7c1e98..dd8d2e71 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateResourcePoolPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateResourcePoolPayload.java @@ -109,9 +109,7 @@ public UpdateResourcePoolPayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the resource pool keys are - * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot - * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the resource pool. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateShareExportPolicyPayload.java index fe37ecf9..7f7e2e15 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateShareExportPolicyPayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateShareExportPolicyPayload.java @@ -63,10 +63,7 @@ public UpdateShareExportPolicyPayload putLabelsItem(String key, String labelsIte } /** - * An optional object that represents the labels associated with the share export policy keys - * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and - * cannot be empty values are validated using the following regex - * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share export policy. * * @return labels */ diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateSharePayload.java index 1d31ce91..2ed817ee 100644 --- a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateSharePayload.java +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/v1betaapi/model/UpdateSharePayload.java @@ -87,9 +87,7 @@ public UpdateSharePayload putLabelsItem(String key, String labelsItem) { } /** - * An optional object that represents the labels associated with the share keys are validated - * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty - * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * An optional object that represents the labels associated with the share. * * @return labels */