From da96d92230f76923e8896fafa9a39ade3cffc368 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Thu, 17 Sep 2026 13:10:38 +0000 Subject: [PATCH] Generate objectstorage --- services/objectstorage/oas_commit | 2 +- .../stackit/sdk/objectstorage/v1api/JSON.java | 3 + .../objectstorage/v1api/api/DefaultApi.java | 52 +++ .../v1api/model/RateLimitError.java | 410 ++++++++++++++++++ .../stackit/sdk/objectstorage/v2api/JSON.java | 3 + .../objectstorage/v2api/api/DefaultApi.java | 52 +++ .../v2api/model/RateLimitError.java | 410 ++++++++++++++++++ 7 files changed, 931 insertions(+), 1 deletion(-) create mode 100644 services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/model/RateLimitError.java create mode 100644 services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/model/RateLimitError.java diff --git a/services/objectstorage/oas_commit b/services/objectstorage/oas_commit index f1d301ef..f97a377b 100644 --- a/services/objectstorage/oas_commit +++ b/services/objectstorage/oas_commit @@ -1 +1 @@ -0c4c4c22a2db77c6bcc0e27e513531d1c25d4fe1 +7408ea178847022c7d5f93abb83d4baac983d677 diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/JSON.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/JSON.java index 128e4896..e66e5543 100644 --- a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/JSON.java +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/JSON.java @@ -169,6 +169,9 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.objectstorage.v1api.model.ProjectStatus .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.objectstorage.v1api.model.RateLimitError + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.objectstorage.v1api.model.SetDefaultRetentionPayload .CustomTypeAdapterFactory()); diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/api/DefaultApi.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/api/DefaultApi.java index 0b70dbe9..f9c62808 100644 --- a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/api/DefaultApi.java +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/api/DefaultApi.java @@ -140,6 +140,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -250,6 +251,7 @@ private okhttp3.Call createAccessKeyValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -281,6 +283,7 @@ public CreateAccessKeyResponse createAccessKey( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -315,6 +318,7 @@ public ApiResponse createAccessKeyWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -352,6 +356,7 @@ public okhttp3.Call createAccessKeyAsync( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -467,6 +472,7 @@ private okhttp3.Call createBucketValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -500,6 +506,7 @@ public CreateBucketResponse createBucket( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -535,6 +542,7 @@ public ApiResponse createBucketWithHttpInfo( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -736,6 +744,7 @@ public okhttp3.Call createComplianceLockAsync( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -839,6 +848,7 @@ private okhttp3.Call createCredentialsGroupValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -869,6 +879,7 @@ public CreateCredentialsGroupResponse createCredentialsGroup( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -902,6 +913,7 @@ public ApiResponse createCredentialsGroupWithHtt * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -938,6 +950,7 @@ public okhttp3.Call createCredentialsGroupAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1052,6 +1065,7 @@ private okhttp3.Call deleteAccessKeyValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1084,6 +1098,7 @@ public DeleteAccessKeyResponse deleteAccessKey( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1118,6 +1133,7 @@ public ApiResponse deleteAccessKeyWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1151,6 +1167,7 @@ public okhttp3.Call deleteAccessKeyAsync( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1255,6 +1272,7 @@ private okhttp3.Call deleteBucketValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1282,6 +1300,7 @@ public DeleteBucketResponse deleteBucket( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1310,6 +1329,7 @@ public ApiResponse deleteBucketWithHttpInfo( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1508,6 +1528,7 @@ public okhttp3.Call deleteComplianceLockAsync( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1613,6 +1634,7 @@ private okhttp3.Call deleteCredentialsGroupValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1641,6 +1663,7 @@ public DeleteCredentialsGroupResponse deleteCredentialsGroup( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1671,6 +1694,7 @@ public ApiResponse deleteCredentialsGroupWithHtt * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1896,6 +1920,7 @@ public okhttp3.Call deleteDefaultRetentionAsync( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1989,6 +2014,7 @@ private okhttp3.Call disableServiceValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2016,6 +2042,7 @@ public ProjectStatus disableService(@javax.annotation.Nonnull String projectId) * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2045,6 +2072,7 @@ public ApiResponse disableServiceWithHttpInfo( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2075,6 +2103,7 @@ public okhttp3.Call disableServiceAsync( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2168,6 +2197,7 @@ private okhttp3.Call enableServiceValidateBeforeCall( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2195,6 +2225,7 @@ public ProjectStatus enableService(@javax.annotation.Nonnull String projectId) * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2224,6 +2255,7 @@ public ApiResponse enableServiceWithHttpInfo( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2254,6 +2286,7 @@ public okhttp3.Call enableServiceAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2359,6 +2392,7 @@ private okhttp3.Call getBucketValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2386,6 +2420,7 @@ public GetBucketResponse getBucket( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2415,6 +2450,7 @@ public ApiResponse getBucketWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2982,6 +3018,7 @@ public okhttp3.Call getDefaultRetentionAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3073,6 +3110,7 @@ private okhttp3.Call getServiceStatusValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3098,6 +3136,7 @@ public ProjectStatus getServiceStatus(@javax.annotation.Nonnull String projectId * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3125,6 +3164,7 @@ public ApiResponse getServiceStatusWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3155,6 +3195,7 @@ public okhttp3.Call getServiceStatusAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3256,6 +3297,7 @@ private okhttp3.Call listAccessKeysValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3285,6 +3327,7 @@ public ListAccessKeysResponse listAccessKeys( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3316,6 +3359,7 @@ public ApiResponse listAccessKeysWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3348,6 +3392,7 @@ public okhttp3.Call listAccessKeysAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3439,6 +3484,7 @@ private okhttp3.Call listBucketsValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3464,6 +3510,7 @@ public ListBucketsResponse listBuckets(@javax.annotation.Nonnull String projectI * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3491,6 +3538,7 @@ public ApiResponse listBucketsWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3520,6 +3568,7 @@ public okhttp3.Call listBucketsAsync( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3610,6 +3659,7 @@ private okhttp3.Call listCredentialsGroupsValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3635,6 +3685,7 @@ public ListCredentialsGroupsResponse listCredentialsGroups( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3662,6 +3713,7 @@ public ApiResponse listCredentialsGroupsWithHttpI * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/model/RateLimitError.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/model/RateLimitError.java new file mode 100644 index 00000000..4ff1bb7d --- /dev/null +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v1api/model/RateLimitError.java @@ -0,0 +1,410 @@ +/* + * STACKIT Object Storage API + * STACKIT API to manage the Object Storage + * + * The version of the OpenAPI document: 1.1.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.objectstorage.v1api.model; + +import cloud.stackit.sdk.objectstorage.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.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** RateLimitError */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class RateLimitError { + public static final String SERIALIZED_NAME_ERROR = "error"; + + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable private String error; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable private String message; + + public static final String SERIALIZED_NAME_PATH = "path"; + + @SerializedName(SERIALIZED_NAME_PATH) + @javax.annotation.Nullable private String path; + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable private Integer status; + + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + @javax.annotation.Nullable private OffsetDateTime timestamp; + + public RateLimitError() {} + + public RateLimitError error(@javax.annotation.Nullable String error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @javax.annotation.Nullable public String getError() { + return error; + } + + public void setError(@javax.annotation.Nullable String error) { + this.error = error; + } + + public RateLimitError message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @javax.annotation.Nullable public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + public RateLimitError path(@javax.annotation.Nullable String path) { + this.path = path; + return this; + } + + /** + * Get path + * + * @return path + */ + @javax.annotation.Nullable public String getPath() { + return path; + } + + public void setPath(@javax.annotation.Nullable String path) { + this.path = path; + } + + public RateLimitError status(@javax.annotation.Nullable Integer status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nullable public Integer getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable Integer status) { + this.status = status; + } + + public RateLimitError timestamp(@javax.annotation.Nullable OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * + * @return timestamp + */ + @javax.annotation.Nullable public OffsetDateTime getTimestamp() { + return timestamp; + } + + public void setTimestamp(@javax.annotation.Nullable OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * 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 RateLimitError instance itself + */ + public RateLimitError 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; + } + RateLimitError rateLimitError = (RateLimitError) o; + return Objects.equals(this.error, rateLimitError.error) + && Objects.equals(this.message, rateLimitError.message) + && Objects.equals(this.path, rateLimitError.path) + && Objects.equals(this.status, rateLimitError.status) + && Objects.equals(this.timestamp, rateLimitError.timestamp) + && Objects.equals(this.additionalProperties, rateLimitError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(error, message, path, status, timestamp, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RateLimitError {\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).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("error", "message", "path", "status", "timestamp")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * 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 RateLimitError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RateLimitError.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 RateLimitError is not found in the empty JSON string", + RateLimitError.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) + && !jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `error` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("error").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) + && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `message` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("message").toString())); + } + if ((jsonObj.get("path") != null && !jsonObj.get("path").isJsonNull()) + && !jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `path` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("path").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RateLimitError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RateLimitError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(RateLimitError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RateLimitError 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 RateLimitError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RateLimitError 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 RateLimitError given an JSON string + * + * @param jsonString JSON string + * @return An instance of RateLimitError + * @throws IOException if the JSON string is invalid with respect to RateLimitError + */ + public static RateLimitError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RateLimitError.class); + } + + /** + * Convert an instance of RateLimitError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/JSON.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/JSON.java index 4d61b9ea..6e02fb0d 100644 --- a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/JSON.java +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/JSON.java @@ -169,6 +169,9 @@ private static Class getClassByDiscriminator( gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.objectstorage.v2api.model.ProjectStatus .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.objectstorage.v2api.model.RateLimitError + .CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory( new cloud.stackit.sdk.objectstorage.v2api.model.SetDefaultRetentionPayload .CustomTypeAdapterFactory()); diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/api/DefaultApi.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/api/DefaultApi.java index e8690b7d..3557ecfb 100644 --- a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/api/DefaultApi.java +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/api/DefaultApi.java @@ -141,6 +141,7 @@ public void setCustomBaseUrl(String customBaseUrl) { * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -264,6 +265,7 @@ private okhttp3.Call createAccessKeyValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -298,6 +300,7 @@ public CreateAccessKeyResponse createAccessKey( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -334,6 +337,7 @@ public ApiResponse createAccessKeyWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -373,6 +377,7 @@ public okhttp3.Call createAccessKeyAsync( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -500,6 +505,7 @@ private okhttp3.Call createBucketValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -535,6 +541,7 @@ public CreateBucketResponse createBucket( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -573,6 +580,7 @@ public ApiResponse createBucketWithHttpInfo( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -798,6 +806,7 @@ public okhttp3.Call createComplianceLockAsync( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -914,6 +923,7 @@ private okhttp3.Call createCredentialsGroupValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -947,6 +957,7 @@ public CreateCredentialsGroupResponse createCredentialsGroup( * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -982,6 +993,7 @@ public ApiResponse createCredentialsGroupWithHtt * 404 Not Found - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1020,6 +1032,7 @@ public okhttp3.Call createCredentialsGroupAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1146,6 +1159,7 @@ private okhttp3.Call deleteAccessKeyValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1180,6 +1194,7 @@ public DeleteAccessKeyResponse deleteAccessKey( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1216,6 +1231,7 @@ public ApiResponse deleteAccessKeyWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1252,6 +1268,7 @@ public okhttp3.Call deleteAccessKeyAsync( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1368,6 +1385,7 @@ private okhttp3.Call deleteBucketValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1398,6 +1416,7 @@ public DeleteBucketResponse deleteBucket( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1430,6 +1449,7 @@ public ApiResponse deleteBucketWithHttpInfo( * 401 Unauthorized - * 404 Not Found - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1651,6 +1671,7 @@ public okhttp3.Call deleteComplianceLockAsync( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1768,6 +1789,7 @@ private okhttp3.Call deleteCredentialsGroupValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1799,6 +1821,7 @@ public DeleteCredentialsGroupResponse deleteCredentialsGroup( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -1832,6 +1855,7 @@ public ApiResponse deleteCredentialsGroupWithHtt * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2079,6 +2103,7 @@ public okhttp3.Call deleteDefaultRetentionAsync( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2186,6 +2211,7 @@ private okhttp3.Call disableServiceValidateBeforeCall( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2215,6 +2241,7 @@ public ProjectStatus disableService( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2246,6 +2273,7 @@ public ApiResponse disableServiceWithHttpInfo( * 404 Not Found - * 409 Conflict - * 422 Unprocessable Entity - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2279,6 +2307,7 @@ public okhttp3.Call disableServiceAsync( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2386,6 +2415,7 @@ private okhttp3.Call enableServiceValidateBeforeCall( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2415,6 +2445,7 @@ public ProjectStatus enableService( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2446,6 +2477,7 @@ public ApiResponse enableServiceWithHttpInfo( * 403 Forbidden - * 409 Conflict - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2479,6 +2511,7 @@ public okhttp3.Call enableServiceAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2596,6 +2629,7 @@ private okhttp3.Call getBucketValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2627,6 +2661,7 @@ public GetBucketResponse getBucket( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -2660,6 +2695,7 @@ public ApiResponse getBucketWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3293,6 +3329,7 @@ public okhttp3.Call getDefaultRetentionAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3398,6 +3435,7 @@ private okhttp3.Call getServiceStatusValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3425,6 +3463,7 @@ public ProjectStatus getServiceStatus( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3454,6 +3493,7 @@ public ApiResponse getServiceStatusWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3488,6 +3528,7 @@ public okhttp3.Call getServiceStatusAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3601,6 +3642,7 @@ private okhttp3.Call listAccessKeysValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3632,6 +3674,7 @@ public ListAccessKeysResponse listAccessKeys( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3665,6 +3708,7 @@ public ApiResponse listAccessKeysWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3699,6 +3743,7 @@ public okhttp3.Call listAccessKeysAsync( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3804,6 +3849,7 @@ private okhttp3.Call listBucketsValidateBeforeCall( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3831,6 +3877,7 @@ public ListBucketsResponse listBuckets( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3860,6 +3907,7 @@ public ApiResponse listBucketsWithHttpInfo( * 403 Forbidden - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3891,6 +3939,7 @@ public okhttp3.Call listBucketsAsync( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -3995,6 +4044,7 @@ private okhttp3.Call listCredentialsGroupsValidateBeforeCall( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -4022,6 +4072,7 @@ public ListCredentialsGroupsResponse listCredentialsGroups( * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ @@ -4052,6 +4103,7 @@ public ApiResponse listCredentialsGroupsWithHttpI * 401 Unauthorized - * 404 Not Found - * 422 Validation Error - + * 429 Too Many Requests - * 500 Internal Server Error - * */ diff --git a/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/model/RateLimitError.java b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/model/RateLimitError.java new file mode 100644 index 00000000..10bfeb5f --- /dev/null +++ b/services/objectstorage/src/main/java/cloud/stackit/sdk/objectstorage/v2api/model/RateLimitError.java @@ -0,0 +1,410 @@ +/* + * STACKIT Object Storage API + * STACKIT API to manage the Object Storage + * + * The version of the OpenAPI document: 2.0.1 + * + * + * 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.objectstorage.v2api.model; + +import cloud.stackit.sdk.objectstorage.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.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** RateLimitError */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class RateLimitError { + public static final String SERIALIZED_NAME_ERROR = "error"; + + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nullable private String error; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable private String message; + + public static final String SERIALIZED_NAME_PATH = "path"; + + @SerializedName(SERIALIZED_NAME_PATH) + @javax.annotation.Nullable private String path; + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable private Integer status; + + public static final String SERIALIZED_NAME_TIMESTAMP = "timestamp"; + + @SerializedName(SERIALIZED_NAME_TIMESTAMP) + @javax.annotation.Nullable private OffsetDateTime timestamp; + + public RateLimitError() {} + + public RateLimitError error(@javax.annotation.Nullable String error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @javax.annotation.Nullable public String getError() { + return error; + } + + public void setError(@javax.annotation.Nullable String error) { + this.error = error; + } + + public RateLimitError message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @javax.annotation.Nullable public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + public RateLimitError path(@javax.annotation.Nullable String path) { + this.path = path; + return this; + } + + /** + * Get path + * + * @return path + */ + @javax.annotation.Nullable public String getPath() { + return path; + } + + public void setPath(@javax.annotation.Nullable String path) { + this.path = path; + } + + public RateLimitError status(@javax.annotation.Nullable Integer status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nullable public Integer getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nullable Integer status) { + this.status = status; + } + + public RateLimitError timestamp(@javax.annotation.Nullable OffsetDateTime timestamp) { + this.timestamp = timestamp; + return this; + } + + /** + * Get timestamp + * + * @return timestamp + */ + @javax.annotation.Nullable public OffsetDateTime getTimestamp() { + return timestamp; + } + + public void setTimestamp(@javax.annotation.Nullable OffsetDateTime timestamp) { + this.timestamp = timestamp; + } + + /** + * 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 RateLimitError instance itself + */ + public RateLimitError 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; + } + RateLimitError rateLimitError = (RateLimitError) o; + return Objects.equals(this.error, rateLimitError.error) + && Objects.equals(this.message, rateLimitError.message) + && Objects.equals(this.path, rateLimitError.path) + && Objects.equals(this.status, rateLimitError.status) + && Objects.equals(this.timestamp, rateLimitError.timestamp) + && Objects.equals(this.additionalProperties, rateLimitError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(error, message, path, status, timestamp, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RateLimitError {\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" timestamp: ").append(toIndentedString(timestamp)).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("error", "message", "path", "status", "timestamp")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * 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 RateLimitError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!RateLimitError.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 RateLimitError is not found in the empty JSON string", + RateLimitError.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("error") != null && !jsonObj.get("error").isJsonNull()) + && !jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `error` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("error").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) + && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `message` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("message").toString())); + } + if ((jsonObj.get("path") != null && !jsonObj.get("path").isJsonNull()) + && !jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `path` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("path").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!RateLimitError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'RateLimitError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(RateLimitError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, RateLimitError 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 RateLimitError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + RateLimitError 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 RateLimitError given an JSON string + * + * @param jsonString JSON string + * @return An instance of RateLimitError + * @throws IOException if the JSON string is invalid with respect to RateLimitError + */ + public static RateLimitError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, RateLimitError.class); + } + + /** + * Convert an instance of RateLimitError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +}