From a566e706910b52a032143fb844effa58f7227a76 Mon Sep 17 00:00:00 2001 From: Marcel Jacek Date: Mon, 31 Aug 2026 13:48:31 +0200 Subject: [PATCH 1/4] feat(automation): onboard automation service --- .../LoadbalancerOptionAccessControl.java | 50 +- services/automation/README.md | 80 + services/automation/build.gradle | 19 + .../sdk/automation/v1betaapi/ApiCallback.java | 60 + .../sdk/automation/v1betaapi/ApiClient.java | 1600 +++++++++++ .../sdk/automation/v1betaapi/ApiResponse.java | 73 + .../v1betaapi/GzipRequestInterceptor.java | 87 + .../sdk/automation/v1betaapi/JSON.java | 666 +++++ .../sdk/automation/v1betaapi/Pair.java | 36 + .../v1betaapi/ProgressRequestBody.java | 71 + .../v1betaapi/ProgressResponseBody.java | 68 + .../v1betaapi/ServerConfiguration.java | 77 + .../automation/v1betaapi/ServerVariable.java | 35 + .../sdk/automation/v1betaapi/StringUtil.java | 81 + .../v1betaapi/api/AutomationApi.java | 64 + .../automation/v1betaapi/api/DefaultApi.java | 2389 +++++++++++++++++ .../model/AbstractOpenApiSchema.java | 143 + .../model/AutomationScheduleTrigger.java | 309 +++ .../v1betaapi/model/AutomationTriggers.java | 290 ++ .../model/CreateSnapshotsResult.java | 354 +++ .../model/CreateVolumeAutomationPayload.java | 444 +++ .../v1betaapi/model/ErrorInfoDetail.java | 406 +++ .../v1betaapi/model/ErrorResponse.java | 299 +++ .../v1betaapi/model/ErrorResponseContent.java | 422 +++ .../model/ErrorResponseContentDetails.java | 350 +++ .../v1betaapi/model/EventCreateResponse.java | 306 +++ .../v1betaapi/model/GetVolumeIDsResult.java | 351 +++ .../model/GetVolumeTemplateResponse.java | 467 ++++ .../v1betaapi/model/HelpErrorDetail.java | 373 +++ .../v1betaapi/model/ListAutomationsItem.java | 508 ++++ .../model/ListAutomationsResponse.java | 360 +++ .../v1betaapi/model/ListExecutionsItem.java | 456 ++++ .../model/ListExecutionsResponse.java | 358 +++ .../model/ListTemplatesResponse.java | 358 +++ .../model/LocalizedMessageErrorDetail.java | 378 +++ .../PartialUpdateVolumeAutomationPayload.java | 399 +++ .../automation/v1betaapi/model/Schedule.java | 324 +++ .../v1betaapi/model/ScheduleDetails.java | 359 +++ .../v1betaapi/model/SchedulePatchRequest.java | 360 +++ .../v1betaapi/model/ScheduleRequest.java | 373 +++ .../model/SnapshotRetentionPolicy.java | 304 +++ .../model/SnapshotRetentionPolicyCount.java | 394 +++ .../SnapshotRetentionPolicyIndefinitely.java | 370 +++ .../automation/v1betaapi/model/Template.java | 402 +++ .../v1betaapi/model/VolumeAutomation.java | 569 ++++ .../model/VolumeAutomationInput.java | 234 ++ .../model/VolumeExecutionAutomation.java | 537 ++++ .../model/VolumeExecutionDetails.java | 331 +++ .../model/VolumeExecutionOutput.java | 315 +++ .../model/VolumeExecutionOutputStep.java | 464 ++++ .../model/VolumeExecutionResponse.java | 489 ++++ .../v1betaapi/model/VolumeOutput.java | 312 +++ .../v1betaapi/model/VolumeOutputStep.java | 334 +++ .../model/VolumeOutputStepResult.java | 289 ++ .../VolumeRecoveryPointManagementInput.java | 475 ++++ .../model/VolumeTemplateAutomationInput.java | 368 +++ .../v1betaapi/api/AutomationApiTest.java | 67 + .../v1betaapi/api/DefaultApiTest.java | 66 + 58 files changed, 20519 insertions(+), 4 deletions(-) create mode 100644 services/automation/README.md create mode 100644 services/automation/build.gradle create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiCallback.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiClient.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/GzipRequestInterceptor.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/JSON.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/Pair.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressRequestBody.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressResponseBody.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerConfiguration.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerVariable.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/StringUtil.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/AutomationApi.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/DefaultApi.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AbstractOpenApiSchema.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationScheduleTrigger.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationTriggers.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateSnapshotsResult.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateVolumeAutomationPayload.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorInfoDetail.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContent.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContentDetails.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/EventCreateResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeIDsResult.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeTemplateResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/HelpErrorDetail.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsItem.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsItem.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListTemplatesResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/LocalizedMessageErrorDetail.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/PartialUpdateVolumeAutomationPayload.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/Schedule.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ScheduleDetails.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/SchedulePatchRequest.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ScheduleRequest.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/SnapshotRetentionPolicy.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/SnapshotRetentionPolicyCount.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/SnapshotRetentionPolicyIndefinitely.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/Template.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeAutomation.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeAutomationInput.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeExecutionAutomation.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeExecutionDetails.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeExecutionOutput.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeExecutionOutputStep.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeExecutionResponse.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeOutput.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeOutputStep.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeOutputStepResult.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeRecoveryPointManagementInput.java create mode 100644 services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/VolumeTemplateAutomationInput.java create mode 100644 services/automation/src/test/java/cloud/stackit/sdk/automation/v1betaapi/api/AutomationApiTest.java create mode 100644 services/automation/src/test/java/cloud/stackit/sdk/automation/v1betaapi/api/DefaultApiTest.java diff --git a/services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/LoadbalancerOptionAccessControl.java b/services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/LoadbalancerOptionAccessControl.java index fa04eec7..853c5433 100644 --- a/services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/LoadbalancerOptionAccessControl.java +++ b/services/alb/src/main/java/cloud/stackit/sdk/alb/v2api/model/LoadbalancerOptionAccessControl.java @@ -31,7 +31,10 @@ import java.util.Map; import java.util.Objects; -/** Use this option to limit the IP ranges that can use the Application Load Balancer. */ +/** + * Use this option to limit the IP ranges that can use the Application Load Balancer. Only one of + * `allowed_source_ranges` or `ip_block_list_name` may be set at the same time. + */ @javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") public class LoadbalancerOptionAccessControl { public static final String SERIALIZED_NAME_ALLOWED_SOURCE_RANGES = "allowedSourceRanges"; @@ -39,6 +42,11 @@ public class LoadbalancerOptionAccessControl { @SerializedName(SERIALIZED_NAME_ALLOWED_SOURCE_RANGES) @javax.annotation.Nullable private List allowedSourceRanges = new ArrayList<>(); + public static final String SERIALIZED_NAME_IP_BLOCK_LIST_NAME = "ipBlockListName"; + + @SerializedName(SERIALIZED_NAME_IP_BLOCK_LIST_NAME) + @javax.annotation.Nullable private String ipBlockListName; + public LoadbalancerOptionAccessControl() {} public LoadbalancerOptionAccessControl allowedSourceRanges( @@ -57,7 +65,8 @@ public LoadbalancerOptionAccessControl addAllowedSourceRangesItem( } /** - * Application Load Balancer is accessible only from an IP address in this range + * Application Load Balancer is accessible only from an IP address in this range. Mutually + * exclusive with `ipBlockListName`. * * @return allowedSourceRanges */ @@ -70,6 +79,27 @@ public void setAllowedSourceRanges( this.allowedSourceRanges = allowedSourceRanges; } + public LoadbalancerOptionAccessControl ipBlockListName( + @javax.annotation.Nullable String ipBlockListName) { + this.ipBlockListName = ipBlockListName; + return this; + } + + /** + * Reference to an IP block list by name. Traffic originating from any IP in the referenced list + * is denied access to the Application Load Balancer. See \"IP Lists API\" for how to + * manage IP block lists. Mutually exclusive with `allowedSourceRanges`. + * + * @return ipBlockListName + */ + @javax.annotation.Nullable public String getIpBlockListName() { + return ipBlockListName; + } + + public void setIpBlockListName(@javax.annotation.Nullable String ipBlockListName) { + this.ipBlockListName = ipBlockListName; + } + /** * A container for additional, undeclared properties. This is a holder for any undeclared * properties as specified with the 'additionalProperties' keyword in the OAS document. @@ -127,6 +157,8 @@ public boolean equals(Object o) { return Objects.equals( this.allowedSourceRanges, loadbalancerOptionAccessControl.allowedSourceRanges) + && Objects.equals( + this.ipBlockListName, loadbalancerOptionAccessControl.ipBlockListName) && Objects.equals( this.additionalProperties, loadbalancerOptionAccessControl.additionalProperties); @@ -134,7 +166,7 @@ public boolean equals(Object o) { @Override public int hashCode() { - return Objects.hash(allowedSourceRanges, additionalProperties); + return Objects.hash(allowedSourceRanges, ipBlockListName, additionalProperties); } @Override @@ -144,6 +176,7 @@ public String toString() { sb.append(" allowedSourceRanges: ") .append(toIndentedString(allowedSourceRanges)) .append("\n"); + sb.append(" ipBlockListName: ").append(toIndentedString(ipBlockListName)).append("\n"); sb.append(" additionalProperties: ") .append(toIndentedString(additionalProperties)) .append("\n"); @@ -167,7 +200,8 @@ private String toIndentedString(Object o) { static { // a set of all properties/fields (JSON key names) - openapiFields = new HashSet(Arrays.asList("allowedSourceRanges")); + openapiFields = + new HashSet(Arrays.asList("allowedSourceRanges", "ipBlockListName")); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(0); @@ -202,6 +236,14 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti "Expected the field `allowedSourceRanges` to be an array in the JSON string but got `%s`", jsonObj.get("allowedSourceRanges").toString())); } + if ((jsonObj.get("ipBlockListName") != null && !jsonObj.get("ipBlockListName").isJsonNull()) + && !jsonObj.get("ipBlockListName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `ipBlockListName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("ipBlockListName").toString())); + } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { diff --git a/services/automation/README.md b/services/automation/README.md new file mode 100644 index 00000000..4adb7277 --- /dev/null +++ b/services/automation/README.md @@ -0,0 +1,80 @@ +# STACKIT Java SDK for STACKIT Automation Service API + +This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK. + +## Installation from Maven Central (recommended) + +The release artifacts for this SDK submodule are available on [Maven Central](https://central.sonatype.com/artifact/cloud.stackit.sdk/automation). + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + automation + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() + } + + dependencies { + implementation "cloud.stackit.sdk:automation:" + } +``` + +## Installation from local build + +Building the API client library requires: +1. Java SDK (version 11 to 21 should be supported) installed on your system + +To install the API client library to your local Maven repository, simply execute: + +```shell +./gradlew services:automation:publishToMavenLocal +``` + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + automation + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenLocal() + } + + dependencies { + implementation "cloud.stackit.sdk:automation:" + } +``` + +## Getting Started + +See the [automation examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/automation/src/main/java/cloud/stackit/sdk/automation/examples). + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. diff --git a/services/automation/build.gradle b/services/automation/build.gradle new file mode 100644 index 00000000..314067c8 --- /dev/null +++ b/services/automation/build.gradle @@ -0,0 +1,19 @@ + +ext { + jakarta_annotation_version = "1.3.5" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.9.0' + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' + implementation 'org.openapitools:jackson-databind-nullable:0.2.8' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiCallback.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiCallback.java new file mode 100644 index 00000000..6eb7e771 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiCallback.java @@ -0,0 +1,60 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import cloud.stackit.sdk.core.exception.ApiException; +import java.util.List; +import java.util.Map; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiClient.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiClient.java new file mode 100644 index 00000000..67471af3 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiClient.java @@ -0,0 +1,1600 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.net.ssl.*; +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +/** ApiClient class. */ +public class ApiClient { + + protected String basePath = "https://automation-service.api.stackit.cloud"; + protected List servers = + new ArrayList( + Arrays.asList( + new ServerConfiguration( + "https://automation-service.api.stackit.cloud", + "No description provided", + new HashMap() { + { + put( + "region", + new ServerVariable( + "No description provided", + "global", + new HashSet())); + } + }))); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + protected boolean debugging = false; + protected Map defaultHeaderMap = new HashMap(); + protected Map defaultCookieMap = new HashMap(); + protected String tempFolderPath = null; + + protected DateFormat dateFormat; + protected DateFormat datetimeFormat; + protected boolean lenientDatetimeFormat; + protected int dateLength; + + protected InputStream sslCaCert; + protected boolean verifyingSsl; + protected KeyManager[] keyManagers; + protected String tlsServerName; + + protected OkHttpClient httpClient; + protected JSON json; + + protected HttpLoggingInterceptor loggingInterceptor; + + protected CoreConfiguration configuration; + + /** + * Basic constructor for ApiClient. + * + *

Not recommended for production use, use the one with the OkHttpClient parameter instead. + * + * @throws IOException thrown when a file can not be found + */ + public ApiClient() throws IOException { + this(null, new CoreConfiguration()); + } + + /** + * Basic constructor for ApiClient + * + *

Not recommended for production use, use the one with the OkHttpClient parameter instead. + * + * @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(CoreConfiguration config) throws IOException { + this(null, config); + } + + /** + * Constructor for ApiClient with OkHttpClient parameter. Recommended for production use. + * + * @param httpClient a OkHttpClient object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(OkHttpClient httpClient) throws IOException { + this(httpClient, new CoreConfiguration()); + } + + /** + * Constructor for ApiClient with OkHttpClient parameter. Recommended for production use. + * + * @param httpClient a OkHttpClient object + * @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(OkHttpClient httpClient, CoreConfiguration config) throws IOException { + init(); + + if (config.getCustomEndpoint() != null && !config.getCustomEndpoint().trim().isEmpty()) { + basePath = config.getCustomEndpoint(); + } + if (config.getDefaultHeader() != null) { + defaultHeaderMap = config.getDefaultHeader(); + } + this.configuration = config; + + if (httpClient == null) { + initHttpClient(); + KeyFlowAuthenticator authenticator = new KeyFlowAuthenticator(this.httpClient, config); + this.httpClient = this.httpClient.newBuilder().authenticator(authenticator).build(); + } else { + // Authorization has to be configured manually in case a custom http client object is + // passed + this.httpClient = httpClient; + } + } + + protected void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + protected void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor : interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + protected void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("stackit-sdk-java/automation"); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://automation-service.api.stackit.cloud) + * @return An instance of ApiClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. Default to + * true. NOTE: Do NOT set to false in production code, otherwise you would face multiple types + * of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. Use null to reset to + * default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + * Getter for the field keyManagers. + * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. Use null to reset to + * default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + * Get TLS server name for SNI (Server Name Indication). + * + * @return The TLS server name + */ + public String getTlsServerName() { + return tlsServerName; + } + + /** + * Set TLS server name for SNI (Server Name Indication). This is used to verify the server + * certificate against a specific hostname instead of the hostname in the URL. + * + * @param tlsServerName The TLS server name to use for certificate verification + * @return ApiClient + */ + public ApiClient setTlsServerName(String tlsServerName) { + this.tlsServerName = tlsServerName; + applySslSettings(); + return this; + } + + /** + * Getter for the field dateFormat. + * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Setter for the field dateFormat. + * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link cloud.stackit.sdk.automation.v1betaapi.ApiClient} object + */ + public ApiClient setDateFormat(DateFormat dateFormat) { + JSON.setDateFormat(dateFormat); + return this; + } + + /** + * Set SqlDateFormat. + * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link cloud.stackit.sdk.automation.v1betaapi.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + * Set OffsetDateTimeFormat. + * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link cloud.stackit.sdk.automation.v1betaapi.ApiClient} object + */ + public ApiClient setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setOffsetDateTimeFormat(dateFormat); + return this; + } + + /** + * Set LocalDateFormat. + * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link cloud.stackit.sdk.automation.v1betaapi.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + * Set LenientOnJson. + * + * @param lenientOnJson a boolean + * @return a {@link cloud.stackit.sdk.automation.v1betaapi.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints with file + * response. The default value is null, i.e. using the system's default temporary + * folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values + * must be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = + httpClient + .newBuilder() + .connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS) + .build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). A value of 0 means no timeout, otherwise values must + * be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = + httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). A value of 0 means no timeout, otherwise values + * must be between 1 and {@link java.lang.Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = + httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date + || param instanceof OffsetDateTime + || param instanceof LocalDate) { + // Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + *

Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + *

Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map)) { + return params; + } + + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceFirst("^.*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json + * application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / *" is also + * default to JSON + * + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in the given + * array, use it; otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be returned (not to + * set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given + * array, use it; otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, returns null. If it + * matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and the Content-Type + * response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to deserialize response body, + * i.e. cannot read response body or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + ResponseBody respBody = response.body(); + if (respBody == null) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + try { + if (isJsonMime(contentType)) { + if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Use String-based deserialize for String return type with fallback + return JSON.deserialize(respBodyString, returnType); + } else { + // Use InputStream-based deserialize which supports responses > 2GB + return JSON.deserialize(respBody.byteStream(), returnType); + } + } else if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Expecting string, return the raw response body. + return (T) respBodyString; + } else { + throw new ApiException( + "Content type \"" + + contentType + + "\" is not supported for type: " + + returnType, + response.code(), + response.headers().toMultimap(), + response.body().string()); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Serialize the given Java object into request body according to the object's class and the + * request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to read file content from + * response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) prefix = "download-"; + } + + if (tempFolderPath == null) return Files.createTempFile(prefix, suffix).toFile(); + else return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and data, which is a Java + * object deserialized from response body and would be null when returnType is null. + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue( + new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure( + new ApiException(e), + response.code(), + response.headers().toMultimap()); + return; + } + callback.onSuccess( + result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws cloud.stackit.sdk.core.exception.ApiException If the response has an unsuccessful + * status code or fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + throw new ApiException( + response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Call buildCall( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + Request request = + buildRequest( + baseUrl, + path, + method, + queryParams, + collectionQueryParams, + body, + headerParams, + cookieParams, + formParams, + authNames, + callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Request buildRequest( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = + RequestBody.create( + "", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + List updatedQueryParams = new ArrayList<>(queryParams); + + final Request.Builder reqBuilder = + new Request.Builder() + .url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl( + String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException( + String.format( + java.util.Locale.ROOT, + "Invalid index %d when selecting the host settings. Must be less than %d", + serverIndex, + servers.size())); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())) + .append("=") + .append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader( + "Cookie", + String.format( + java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader( + "Cookie", + String.format( + java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, which could + * contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item : list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = + Headers.of( + "Content-Disposition", + "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody + * Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for async + * requests. + */ + protected Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse + .newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of verifyingSsl and + * sslCaCert. + */ + protected void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = + new TrustManager[] { + new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[] {}; + } + } + }; + hostnameVerifier = + new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = + certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException( + "expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + if (tlsServerName != null && !tlsServerName.isEmpty()) { + hostnameVerifier = + new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + // Verify the certificate against tlsServerName instead of the + // actual hostname + return OkHostnameVerifier.INSTANCE.verify( + tlsServerName, session); + } + }; + } else { + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = + httpClient + .newBuilder() + .sslSocketFactory( + sslContext.getSocketFactory(), + (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object into a string + */ + protected String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiResponse.java new file mode 100644 index 00000000..906a4cbd --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ApiResponse.java @@ -0,0 +1,73 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.util.List; +import java.util.Map; + +/** API response returned by API call. */ +public class ApiResponse { + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * Constructor for ApiResponse. + * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + */ + public ApiResponse(int statusCode, Map> headers) { + this(statusCode, headers, null); + } + + /** + * Constructor for ApiResponse. + * + * @param statusCode The status code of HTTP response + * @param headers The headers of HTTP response + * @param data The object deserialized from response bod + */ + public ApiResponse(int statusCode, Map> headers, T data) { + this.statusCode = statusCode; + this.headers = headers; + this.data = data; + } + + /** + * Get the status code. + * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } + + /** + * Get the headers. + * + * @return a {@link java.util.Map} of headers + */ + public Map> getHeaders() { + return headers; + } + + /** + * Get the data. + * + * @return the data + */ + public T getData() { + return data; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/GzipRequestInterceptor.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/GzipRequestInterceptor.java new file mode 100644 index 00000000..44567399 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/GzipRequestInterceptor.java @@ -0,0 +1,87 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.io.IOException; +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +/** + * Encodes request bodies using gzip. + * + *

Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = + originalRequest + .newBuilder() + .header("Content-Encoding", "gzip") + .method( + originalRequest.method(), + forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/JSON.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/JSON.java new file mode 100644 index 00000000..a3ef19a5 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/JSON.java @@ -0,0 +1,666 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import okio.ByteString; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = + new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = + new GsonFireBuilder() + .registerTypeSelector( + cloud.stackit.sdk.automation.v1betaapi.model + .ErrorResponseContentDetails.class, + new TypeSelector< + cloud.stackit.sdk.automation.v1betaapi.model + .ErrorResponseContentDetails>() { + @Override + public Class< + ? extends + cloud.stackit.sdk.automation.v1betaapi + .model + .ErrorResponseContentDetails> + getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = + new HashMap(); + classByDiscriminatorValue.put( + "ErrorInfo", + cloud.stackit.sdk.automation.v1betaapi.model + .ErrorInfoDetail.class); + classByDiscriminatorValue.put( + "Help", + cloud.stackit.sdk.automation.v1betaapi.model + .HelpErrorDetail.class); + classByDiscriminatorValue.put( + "LocalizedMessage", + cloud.stackit.sdk.automation.v1betaapi.model + .LocalizedMessageErrorDetail.class); + classByDiscriminatorValue.put( + "ErrorResponseContentDetails", + cloud.stackit.sdk.automation.v1betaapi.model + .ErrorResponseContentDetails.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "@type")); + } + }) + .registerTypeSelector( + cloud.stackit.sdk.automation.v1betaapi.model.SnapshotRetentionPolicy + .class, + new TypeSelector< + cloud.stackit.sdk.automation.v1betaapi.model + .SnapshotRetentionPolicy>() { + @Override + public Class< + ? extends + cloud.stackit.sdk.automation.v1betaapi + .model.SnapshotRetentionPolicy> + getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = + new HashMap(); + classByDiscriminatorValue.put( + "count", + cloud.stackit.sdk.automation.v1betaapi.model + .SnapshotRetentionPolicyCount.class); + classByDiscriminatorValue.put( + "indefinitely", + cloud.stackit.sdk.automation.v1betaapi.model + .SnapshotRetentionPolicyIndefinitely.class); + classByDiscriminatorValue.put( + "SnapshotRetentionPolicy", + cloud.stackit.sdk.automation.v1betaapi.model + .SnapshotRetentionPolicy.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "kind")); + } + }) + .registerTypeSelector( + cloud.stackit.sdk.automation.v1betaapi.model.VolumeAutomationInput + .class, + new TypeSelector< + cloud.stackit.sdk.automation.v1betaapi.model + .VolumeAutomationInput>() { + @Override + public Class< + ? extends + cloud.stackit.sdk.automation.v1betaapi + .model.VolumeAutomationInput> + getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = + new HashMap(); + classByDiscriminatorValue.put( + "VolumeRecoveryPointManagement", + cloud.stackit.sdk.automation.v1betaapi.model + .VolumeRecoveryPointManagementInput.class); + classByDiscriminatorValue.put( + "VolumeAutomationInput", + cloud.stackit.sdk.automation.v1betaapi.model + .VolumeAutomationInput.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "kind")); + } + }) + .registerTypeSelector( + cloud.stackit.sdk.automation.v1betaapi.model.VolumeOutputStepResult + .class, + new TypeSelector< + cloud.stackit.sdk.automation.v1betaapi.model + .VolumeOutputStepResult>() { + @Override + public Class< + ? extends + cloud.stackit.sdk.automation.v1betaapi + .model.VolumeOutputStepResult> + getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = + new HashMap(); + classByDiscriminatorValue.put( + "CreateSnapshotsResult", + cloud.stackit.sdk.automation.v1betaapi.model + .CreateSnapshotsResult.class); + classByDiscriminatorValue.put( + "GetVolumeIDsResult", + cloud.stackit.sdk.automation.v1betaapi.model + .GetVolumeIDsResult.class); + classByDiscriminatorValue.put( + "VolumeOutputStepResult", + cloud.stackit.sdk.automation.v1betaapi.model + .VolumeOutputStepResult.class); + return getClassByDiscriminator( + classByDiscriminatorValue, + getDiscriminatorValue(readElement, "kind")); + } + }); + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue( + JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException( + "missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator + * value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator( + Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException( + "cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + static { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.AutomationScheduleTrigger + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.AutomationTriggers + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.CreateSnapshotsResult + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.CreateVolumeAutomationPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ErrorInfoDetail + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ErrorResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ErrorResponseContent + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ErrorResponseContentDetails + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.EventCreateResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.GetVolumeIDsResult + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.GetVolumeTemplateResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.HelpErrorDetail + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ListAutomationsItem + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ListAutomationsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ListExecutionsItem + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ListExecutionsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ListTemplatesResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.LocalizedMessageErrorDetail + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model + .PartialUpdateVolumeAutomationPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.Schedule + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ScheduleDetails + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.SchedulePatchRequest + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.ScheduleRequest + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.SnapshotRetentionPolicy + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.SnapshotRetentionPolicyCount + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.SnapshotRetentionPolicyIndefinitely + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.Template + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeAutomation + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeAutomationInput + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionAutomation + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionDetails + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionOutput + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionOutputStep + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeOutput + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeOutputStep + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeOutputStepResult + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeRecoveryPointManagementInput + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.automation.v1betaapi.model.VolumeTemplateAutomationInput + .CustomTypeAdapterFactory()); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see + // https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Deserialize the given JSON InputStream to a Java object. + * + * @param Type + * @param inputStream The JSON InputStream + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(InputStream inputStream, Type returnType) throws IOException { + try (InputStreamReader reader = + new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { + if (isLenientOnJson) { + // see + // https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + JsonReader jsonReader = new JsonReader(reader); + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(reader, returnType); + } + } + } + + /** Gson TypeAdapter for Byte Array type */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** Gson TypeAdapter for JSR310 OffsetDateTime type */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length() - 5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** Gson TypeAdapter for JSR310 LocalDate type */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type If the dateFormat is null, a simple "yyyy-MM-dd" + * format will be used (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date( + ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type If the dateFormat is null, ISO8601Utils will be + * used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/Pair.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/Pair.java new file mode 100644 index 00000000..cc869ab4 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/Pair.java @@ -0,0 +1,36 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class Pair { + private final String name; + private final String value; + + public Pair(String name, String value) { + this.name = isValidString(name) ? name : ""; + this.value = isValidString(value) ? value : ""; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private static boolean isValidString(String arg) { + return arg != null; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressRequestBody.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressRequestBody.java new file mode 100644 index 00000000..420a0a84 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressRequestBody.java @@ -0,0 +1,71 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress( + bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressResponseBody.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressResponseBody.java new file mode 100644 index 00000000..be3c8da0 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ProgressResponseBody.java @@ -0,0 +1,68 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.ResponseBody; +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress( + totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerConfiguration.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerConfiguration.java new file mode 100644 index 00000000..f4556f5e --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerConfiguration.java @@ -0,0 +1,77 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.util.Map; + +/** Representing a Server configuration. */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ServerConfiguration { + public String URL; + public String description; + public Map variables; + + /** + * @param URL A URL to the target host. + * @param description A description of the host designated by the URL. + * @param variables A map between a variable name and its value. The value is used for + * substitution in the server's URL template. + */ + public ServerConfiguration( + String URL, String description, Map variables) { + this.URL = URL; + this.description = description; + this.variables = variables; + } + + /** + * Format URL template using given variables. + * + * @param variables A map between a variable name and its value. + * @return Formatted URL. + */ + public String URL(Map variables) { + String url = this.URL; + + // go through variables and replace placeholders + for (Map.Entry variable : this.variables.entrySet()) { + String name = variable.getKey(); + ServerVariable serverVariable = variable.getValue(); + String value = serverVariable.defaultValue; + + if (variables != null && variables.containsKey(name)) { + value = variables.get(name); + if (serverVariable.enumValues.size() > 0 + && !serverVariable.enumValues.contains(value)) { + throw new IllegalArgumentException( + "The variable " + + name + + " in the server URL has invalid value " + + value + + "."); + } + } + url = url.replace("{" + name + "}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerVariable.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerVariable.java new file mode 100644 index 00000000..876c61a5 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/ServerVariable.java @@ -0,0 +1,35 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.util.HashSet; + +/** Representing a Server Variable for server URL template substitution. */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are + * from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/StringUtil.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/StringUtil.java new file mode 100644 index 00000000..10621d3a --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/StringUtil.java @@ -0,0 +1,81 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + * + *

Note: This might be replaced by utility method from commons-lang or guava someday if one + * of those libraries is added as dependency. + * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/AutomationApi.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/AutomationApi.java new file mode 100644 index 00000000..b8909464 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/AutomationApi.java @@ -0,0 +1,64 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import java.io.IOException; +import okhttp3.OkHttpClient; + +public class AutomationApi extends DefaultApi { + /** + * Basic constructor for AutomationApi + * + *

For production use consider using the constructor with the OkHttpClient parameter. + * + * @throws IOException + */ + public AutomationApi() throws IOException { + super(); + } + + /** + * Basic Constructor for AutomationApi + * + *

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public AutomationApi(CoreConfiguration configuration) throws IOException { + super(configuration); + } + + /** + * Constructor for AutomationApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public AutomationApi(OkHttpClient httpClient) throws IOException { + super(httpClient); + } + + /** + * Constructor for AutomationApi + * + * @param httpClient OkHttpClient object + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public AutomationApi(OkHttpClient httpClient, CoreConfiguration configuration) + throws IOException { + super(httpClient, configuration); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/DefaultApi.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/DefaultApi.java new file mode 100644 index 00000000..6637cc2d --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/api/DefaultApi.java @@ -0,0 +1,2389 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.api; + +import cloud.stackit.sdk.automation.v1betaapi.ApiCallback; +import cloud.stackit.sdk.automation.v1betaapi.ApiClient; +import cloud.stackit.sdk.automation.v1betaapi.ApiResponse; +import cloud.stackit.sdk.automation.v1betaapi.Pair; +import cloud.stackit.sdk.automation.v1betaapi.model.CreateVolumeAutomationPayload; +import cloud.stackit.sdk.automation.v1betaapi.model.GetVolumeTemplateResponse; +import cloud.stackit.sdk.automation.v1betaapi.model.ListAutomationsResponse; +import cloud.stackit.sdk.automation.v1betaapi.model.ListExecutionsResponse; +import cloud.stackit.sdk.automation.v1betaapi.model.ListTemplatesResponse; +import cloud.stackit.sdk.automation.v1betaapi.model.PartialUpdateVolumeAutomationPayload; +import cloud.stackit.sdk.automation.v1betaapi.model.VolumeAutomation; +import cloud.stackit.sdk.automation.v1betaapi.model.VolumeExecutionResponse; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import okhttp3.OkHttpClient; + +// Package-private access to enforce service-specific API usage (DefaultApi => Api) +class DefaultApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + /** + * Basic constructor for DefaultApi + * + *

For production use consider using the constructor with the OkHttpClient parameter. + * + * @throws IOException + */ + public DefaultApi() throws IOException { + this(null, new CoreConfiguration()); + } + + /** + * Basic Constructor for DefaultApi + * + *

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public DefaultApi(CoreConfiguration config) throws IOException { + this(null, config); + } + + /** + * Constructor for DefaultApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public DefaultApi(OkHttpClient httpClient) throws IOException { + this(httpClient, new CoreConfiguration()); + } + + /** + * Constructor for DefaultApi + * + * @param httpClient OkHttpClient object + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public DefaultApi(OkHttpClient httpClient, CoreConfiguration config) throws IOException { + if (config.getCustomEndpoint() != null && !config.getCustomEndpoint().trim().isEmpty()) { + localCustomBaseUrl = config.getCustomEndpoint(); + } + this.localVarApiClient = new ApiClient(httpClient, config); + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createVolumeAutomation + * + * @param projectId project Id (required) + * @param region region (required) + * @param createVolumeAutomationPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call createVolumeAutomationCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable CreateVolumeAutomationPayload createVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = createVolumeAutomationPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createVolumeAutomationValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable CreateVolumeAutomationPayload createVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling createVolumeAutomation(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createVolumeAutomation(Async)"); + } + + return createVolumeAutomationCall( + projectId, region, createVolumeAutomationPayload, _callback); + } + + /** + * Create volume automation Creates a new volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param createVolumeAutomationPayload (optional) + * @return VolumeAutomation + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public VolumeAutomation createVolumeAutomation( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable CreateVolumeAutomationPayload createVolumeAutomationPayload) + throws ApiException { + ApiResponse localVarResp = + createVolumeAutomationWithHttpInfo( + projectId, region, createVolumeAutomationPayload); + return localVarResp.getData(); + } + + /** + * Create volume automation Creates a new volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param createVolumeAutomationPayload (optional) + * @return ApiResponse<VolumeAutomation> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse createVolumeAutomationWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable CreateVolumeAutomationPayload createVolumeAutomationPayload) + throws ApiException { + okhttp3.Call localVarCall = + createVolumeAutomationValidateBeforeCall( + projectId, region, createVolumeAutomationPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create volume automation (asynchronously) Creates a new volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param createVolumeAutomationPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call createVolumeAutomationAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable CreateVolumeAutomationPayload createVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createVolumeAutomationValidateBeforeCall( + projectId, region, createVolumeAutomationPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createVolumeExecution + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call createVolumeExecutionCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}/executions" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createVolumeExecutionValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling createVolumeExecution(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createVolumeExecution(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling createVolumeExecution(Async)"); + } + + return createVolumeExecutionCall(projectId, region, automationId, _callback); + } + + /** + * Create volume automation executions Creates a new execution for a specific volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @return VolumeExecutionResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public VolumeExecutionResponse createVolumeExecution( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + ApiResponse localVarResp = + createVolumeExecutionWithHttpInfo(projectId, region, automationId); + return localVarResp.getData(); + } + + /** + * Create volume automation executions Creates a new execution for a specific volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @return ApiResponse<VolumeExecutionResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse createVolumeExecutionWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + okhttp3.Call localVarCall = + createVolumeExecutionValidateBeforeCall(projectId, region, automationId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create volume automation executions (asynchronously) Creates a new execution for a specific + * volume automation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
201 Automation created -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call createVolumeExecutionAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createVolumeExecutionValidateBeforeCall(projectId, region, automationId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteVolumeAutomation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 automation deleted -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call deleteVolumeAutomationCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteVolumeAutomationValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling deleteVolumeAutomation(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteVolumeAutomation(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling deleteVolumeAutomation(Async)"); + } + + return deleteVolumeAutomationCall(projectId, region, automationId, _callback); + } + + /** + * Delete volume automation Deletes a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 automation deleted -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public void deleteVolumeAutomation( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + deleteVolumeAutomationWithHttpInfo(projectId, region, automationId); + } + + /** + * Delete volume automation Deletes a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 automation deleted -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse deleteVolumeAutomationWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + okhttp3.Call localVarCall = + deleteVolumeAutomationValidateBeforeCall(projectId, region, automationId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete volume automation (asynchronously) Deletes a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 automation deleted -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call deleteVolumeAutomationAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteVolumeAutomationValidateBeforeCall( + projectId, region, automationId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for getVolumeAutomation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeAutomationCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getVolumeAutomationValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling getVolumeAutomation(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getVolumeAutomation(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling getVolumeAutomation(Async)"); + } + + return getVolumeAutomationCall(projectId, region, automationId, _callback); + } + + /** + * Get volume automation Retrieves a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @return VolumeAutomation + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public VolumeAutomation getVolumeAutomation( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + ApiResponse localVarResp = + getVolumeAutomationWithHttpInfo(projectId, region, automationId); + return localVarResp.getData(); + } + + /** + * Get volume automation Retrieves a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @return ApiResponse<VolumeAutomation> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse getVolumeAutomationWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId) + throws ApiException { + okhttp3.Call localVarCall = + getVolumeAutomationValidateBeforeCall(projectId, region, automationId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get volume automation (asynchronously) Retrieves a specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeAutomationAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getVolumeAutomationValidateBeforeCall(projectId, region, automationId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getVolumeExecution + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param executionId execution Id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeExecutionCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nonnull String executionId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}/executions/{executionId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())) + .replace( + "{" + "executionId" + "}", + localVarApiClient.escapeString(executionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getVolumeExecutionValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nonnull String executionId, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling getVolumeExecution(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getVolumeExecution(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling getVolumeExecution(Async)"); + } + + // verify the required parameter 'executionId' is set + if (executionId == null) { + throw new ApiException( + "Missing the required parameter 'executionId' when calling getVolumeExecution(Async)"); + } + + return getVolumeExecutionCall(projectId, region, automationId, executionId, _callback); + } + + /** + * Get volume automation execution details Get details for a specific volume automation + * execution + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param executionId execution Id (required) + * @return VolumeExecutionResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public VolumeExecutionResponse getVolumeExecution( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nonnull String executionId) + throws ApiException { + ApiResponse localVarResp = + getVolumeExecutionWithHttpInfo(projectId, region, automationId, executionId); + return localVarResp.getData(); + } + + /** + * Get volume automation execution details Get details for a specific volume automation + * execution + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param executionId execution Id (required) + * @return ApiResponse<VolumeExecutionResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse getVolumeExecutionWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nonnull String executionId) + throws ApiException { + okhttp3.Call localVarCall = + getVolumeExecutionValidateBeforeCall( + projectId, region, automationId, executionId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get volume automation execution details (asynchronously) Get details for a specific volume + * automation execution + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param executionId execution Id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeExecutionAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nonnull String executionId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getVolumeExecutionValidateBeforeCall( + projectId, region, automationId, executionId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getVolumeTemplate + * + * @param projectId project Id (required) + * @param region region (required) + * @param templateId templateId Id (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template get response details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeTemplateCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String templateId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/templates/{templateId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "templateId" + "}", + localVarApiClient.escapeString(templateId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getVolumeTemplateValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String templateId, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling getVolumeTemplate(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getVolumeTemplate(Async)"); + } + + // verify the required parameter 'templateId' is set + if (templateId == null) { + throw new ApiException( + "Missing the required parameter 'templateId' when calling getVolumeTemplate(Async)"); + } + + return getVolumeTemplateCall(projectId, region, templateId, _callback); + } + + /** + * Get volume template Retrieve detailed information about a volume template + * + * @param projectId project Id (required) + * @param region region (required) + * @param templateId templateId Id (required) + * @return GetVolumeTemplateResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template get response details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public GetVolumeTemplateResponse getVolumeTemplate( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String templateId) + throws ApiException { + ApiResponse localVarResp = + getVolumeTemplateWithHttpInfo(projectId, region, templateId); + return localVarResp.getData(); + } + + /** + * Get volume template Retrieve detailed information about a volume template + * + * @param projectId project Id (required) + * @param region region (required) + * @param templateId templateId Id (required) + * @return ApiResponse<GetVolumeTemplateResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template get response details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse getVolumeTemplateWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String templateId) + throws ApiException { + okhttp3.Call localVarCall = + getVolumeTemplateValidateBeforeCall(projectId, region, templateId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get volume template (asynchronously) Retrieve detailed information about a volume template + * + * @param projectId project Id (required) + * @param region region (required) + * @param templateId templateId Id (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template get response details -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call getVolumeTemplateAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String templateId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getVolumeTemplateValidateBeforeCall(projectId, region, templateId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listVolumeAutomations + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeAutomationsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + if (pageToken != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageToken", pageToken)); + } + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listVolumeAutomationsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling listVolumeAutomations(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listVolumeAutomations(Async)"); + } + + return listVolumeAutomationsCall(projectId, region, pageSize, pageToken, _callback); + } + + /** + * List volume automations Retrieves a list of volume automations. + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ListAutomationsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ListAutomationsResponse listVolumeAutomations( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + ApiResponse localVarResp = + listVolumeAutomationsWithHttpInfo(projectId, region, pageSize, pageToken); + return localVarResp.getData(); + } + + /** + * List volume automations Retrieves a list of volume automations. + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ApiResponse<ListAutomationsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse listVolumeAutomationsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + okhttp3.Call localVarCall = + listVolumeAutomationsValidateBeforeCall( + projectId, region, pageSize, pageToken, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List volume automations (asynchronously) Retrieves a list of volume automations. + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeAutomationsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listVolumeAutomationsValidateBeforeCall( + projectId, region, pageSize, pageToken, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listVolumeExecutions + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeExecutionsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}/executions" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + if (pageToken != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageToken", pageToken)); + } + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listVolumeExecutionsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling listVolumeExecutions(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listVolumeExecutions(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling listVolumeExecutions(Async)"); + } + + return listVolumeExecutionsCall( + projectId, region, automationId, pageSize, pageToken, _callback); + } + + /** + * List volume automation executions Get a list of all executions for a specific volume + * automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ListExecutionsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ListExecutionsResponse listVolumeExecutions( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + ApiResponse localVarResp = + listVolumeExecutionsWithHttpInfo( + projectId, region, automationId, pageSize, pageToken); + return localVarResp.getData(); + } + + /** + * List volume automation executions Get a list of all executions for a specific volume + * automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ApiResponse<ListExecutionsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse listVolumeExecutionsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + okhttp3.Call localVarCall = + listVolumeExecutionsValidateBeforeCall( + projectId, region, automationId, pageSize, pageToken, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List volume automation executions (asynchronously) Get a list of all executions for a + * specific volume automation. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automations list -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeExecutionsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listVolumeExecutionsValidateBeforeCall( + projectId, region, automationId, pageSize, pageToken, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listVolumeTemplates + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template list response -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeTemplatesCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/templates" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + if (pageToken != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageToken", pageToken)); + } + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listVolumeTemplatesValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling listVolumeTemplates(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listVolumeTemplates(Async)"); + } + + return listVolumeTemplatesCall(projectId, region, pageSize, pageToken, _callback); + } + + /** + * List volume templates Lists all volume templates for the specified service + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ListTemplatesResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template list response -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ListTemplatesResponse listVolumeTemplates( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + ApiResponse localVarResp = + listVolumeTemplatesWithHttpInfo(projectId, region, pageSize, pageToken); + return localVarResp.getData(); + } + + /** + * List volume templates Lists all volume templates for the specified service + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @return ApiResponse<ListTemplatesResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template list response -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse listVolumeTemplatesWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken) + throws ApiException { + okhttp3.Call localVarCall = + listVolumeTemplatesValidateBeforeCall(projectId, region, pageSize, pageToken, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List volume templates (asynchronously) Lists all volume templates for the specified service + * + * @param projectId project Id (required) + * @param region region (required) + * @param pageSize The maximum number of items to return. If unspecified or set to 0, at most + * 100 items will be returned. The maximum value is 100; values above 100 will be coerced to + * 100. (optional, default to 100) + * @param pageToken A page token, received from a previous list call. Provide this to retrieve + * the subsequent page. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 template list response -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call listVolumeTemplatesAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable Integer pageSize, + @javax.annotation.Nullable String pageToken, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listVolumeTemplatesValidateBeforeCall( + projectId, region, pageSize, pageToken, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for partialUpdateVolumeAutomation + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param updateMask A comma-separated list of fully qualified names of fields to be updated. + * Example: \"name,triggers.schedule.rrule\" (optional) + * @param partialUpdateVolumeAutomationPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation updated -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call partialUpdateVolumeAutomationCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable String updateMask, + @javax.annotation.Nullable PartialUpdateVolumeAutomationPayload partialUpdateVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = partialUpdateVolumeAutomationPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/services/volumes/automations/{automationId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "automationId" + "}", + localVarApiClient.escapeString(automationId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (updateMask != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("updateMask", updateMask)); + } + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "PATCH", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call partialUpdateVolumeAutomationValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable String updateMask, + @javax.annotation.Nullable PartialUpdateVolumeAutomationPayload partialUpdateVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling partialUpdateVolumeAutomation(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling partialUpdateVolumeAutomation(Async)"); + } + + // verify the required parameter 'automationId' is set + if (automationId == null) { + throw new ApiException( + "Missing the required parameter 'automationId' when calling partialUpdateVolumeAutomation(Async)"); + } + + return partialUpdateVolumeAutomationCall( + projectId, + region, + automationId, + updateMask, + partialUpdateVolumeAutomationPayload, + _callback); + } + + /** + * Patch volume automation Partially updates a specific volume automation. Specify the fields to + * update in the `updateMask` query parameter. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param updateMask A comma-separated list of fully qualified names of fields to be updated. + * Example: \"name,triggers.schedule.rrule\" (optional) + * @param partialUpdateVolumeAutomationPayload (optional) + * @return VolumeAutomation + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation updated -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public VolumeAutomation partialUpdateVolumeAutomation( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable String updateMask, + @javax.annotation.Nullable PartialUpdateVolumeAutomationPayload partialUpdateVolumeAutomationPayload) + throws ApiException { + ApiResponse localVarResp = + partialUpdateVolumeAutomationWithHttpInfo( + projectId, + region, + automationId, + updateMask, + partialUpdateVolumeAutomationPayload); + return localVarResp.getData(); + } + + /** + * Patch volume automation Partially updates a specific volume automation. Specify the fields to + * update in the `updateMask` query parameter. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param updateMask A comma-separated list of fully qualified names of fields to be updated. + * Example: \"name,triggers.schedule.rrule\" (optional) + * @param partialUpdateVolumeAutomationPayload (optional) + * @return ApiResponse<VolumeAutomation> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation updated -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public ApiResponse partialUpdateVolumeAutomationWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable String updateMask, + @javax.annotation.Nullable PartialUpdateVolumeAutomationPayload partialUpdateVolumeAutomationPayload) + throws ApiException { + okhttp3.Call localVarCall = + partialUpdateVolumeAutomationValidateBeforeCall( + projectId, + region, + automationId, + updateMask, + partialUpdateVolumeAutomationPayload, + null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Patch volume automation (asynchronously) Partially updates a specific volume automation. + * Specify the fields to update in the `updateMask` query parameter. + * + * @param projectId project Id (required) + * @param region region (required) + * @param automationId automation Id (required) + * @param updateMask A comma-separated list of fully qualified names of fields to be updated. + * Example: \"name,triggers.schedule.rrule\" (optional) + * @param partialUpdateVolumeAutomationPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 automation updated -
400 Bad Request -
401 Unauthorized -
403 Not found -
404 Not found -
+ */ + public okhttp3.Call partialUpdateVolumeAutomationAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String automationId, + @javax.annotation.Nullable String updateMask, + @javax.annotation.Nullable PartialUpdateVolumeAutomationPayload partialUpdateVolumeAutomationPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + partialUpdateVolumeAutomationValidateBeforeCall( + projectId, + region, + automationId, + updateMask, + partialUpdateVolumeAutomationPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AbstractOpenApiSchema.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AbstractOpenApiSchema.java new file mode 100644 index 00000000..24766f0d --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AbstractOpenApiSchema.java @@ -0,0 +1,143 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + // @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).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 boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationScheduleTrigger.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationScheduleTrigger.java new file mode 100644 index 00000000..0a0b2e06 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationScheduleTrigger.java @@ -0,0 +1,309 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** AutomationScheduleTrigger */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class AutomationScheduleTrigger { + public static final String SERIALIZED_NAME_RRULE = "rrule"; + + @SerializedName(SERIALIZED_NAME_RRULE) + @javax.annotation.Nonnull + private String rrule; + + public AutomationScheduleTrigger() {} + + public AutomationScheduleTrigger rrule(@javax.annotation.Nonnull String rrule) { + this.rrule = rrule; + return this; + } + + /** + * An rrule (Recurrence Rule) is a standardized string format used in iCalendar (RFC 5545) to + * define repeating events, and you can generate one by using a dedicated library or by using + * online generator tools to specify parameters like frequency, interval, and end dates + * + * @return rrule + */ + @javax.annotation.Nonnull + public String getRrule() { + return rrule; + } + + public void setRrule(@javax.annotation.Nonnull String rrule) { + this.rrule = rrule; + } + + /** + * 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 AutomationScheduleTrigger instance itself + */ + public AutomationScheduleTrigger 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; + } + AutomationScheduleTrigger automationScheduleTrigger = (AutomationScheduleTrigger) o; + return Objects.equals(this.rrule, automationScheduleTrigger.rrule) + && Objects.equals( + this.additionalProperties, automationScheduleTrigger.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(rrule, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AutomationScheduleTrigger {\n"); + sb.append(" rrule: ").append(toIndentedString(rrule)).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("rrule")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("rrule")); + } + + /** + * 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 AutomationScheduleTrigger + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!AutomationScheduleTrigger.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 AutomationScheduleTrigger is not found in the empty JSON string", + AutomationScheduleTrigger.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : AutomationScheduleTrigger.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("rrule").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `rrule` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("rrule").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AutomationScheduleTrigger.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AutomationScheduleTrigger' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(AutomationScheduleTrigger.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, AutomationScheduleTrigger 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 AutomationScheduleTrigger read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AutomationScheduleTrigger 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 AutomationScheduleTrigger given an JSON string + * + * @param jsonString JSON string + * @return An instance of AutomationScheduleTrigger + * @throws IOException if the JSON string is invalid with respect to AutomationScheduleTrigger + */ + public static AutomationScheduleTrigger fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AutomationScheduleTrigger.class); + } + + /** + * Convert an instance of AutomationScheduleTrigger to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationTriggers.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationTriggers.java new file mode 100644 index 00000000..74309431 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/AutomationTriggers.java @@ -0,0 +1,290 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** AutomationTriggers */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class AutomationTriggers { + public static final String SERIALIZED_NAME_SCHEDULE = "schedule"; + + @SerializedName(SERIALIZED_NAME_SCHEDULE) + @javax.annotation.Nullable private AutomationScheduleTrigger schedule; + + public AutomationTriggers() {} + + public AutomationTriggers schedule( + @javax.annotation.Nullable AutomationScheduleTrigger schedule) { + this.schedule = schedule; + return this; + } + + /** + * Get schedule + * + * @return schedule + */ + @javax.annotation.Nullable public AutomationScheduleTrigger getSchedule() { + return schedule; + } + + public void setSchedule(@javax.annotation.Nullable AutomationScheduleTrigger schedule) { + this.schedule = schedule; + } + + /** + * 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 AutomationTriggers instance itself + */ + public AutomationTriggers 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; + } + AutomationTriggers automationTriggers = (AutomationTriggers) o; + return Objects.equals(this.schedule, automationTriggers.schedule) + && Objects.equals( + this.additionalProperties, automationTriggers.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(schedule, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class AutomationTriggers {\n"); + sb.append(" schedule: ").append(toIndentedString(schedule)).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("schedule")); + + // 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 AutomationTriggers + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!AutomationTriggers.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 AutomationTriggers is not found in the empty JSON string", + AutomationTriggers.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `schedule` + if (jsonObj.get("schedule") != null && !jsonObj.get("schedule").isJsonNull()) { + AutomationScheduleTrigger.validateJsonElement(jsonObj.get("schedule")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!AutomationTriggers.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'AutomationTriggers' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(AutomationTriggers.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, AutomationTriggers 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 AutomationTriggers read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + AutomationTriggers 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 AutomationTriggers given an JSON string + * + * @param jsonString JSON string + * @return An instance of AutomationTriggers + * @throws IOException if the JSON string is invalid with respect to AutomationTriggers + */ + public static AutomationTriggers fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, AutomationTriggers.class); + } + + /** + * Convert an instance of AutomationTriggers to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateSnapshotsResult.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateSnapshotsResult.java new file mode 100644 index 00000000..45763d69 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateSnapshotsResult.java @@ -0,0 +1,354 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** CreateSnapshotsResult */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class CreateSnapshotsResult { + public static final String SERIALIZED_NAME_CREATED_SNAPSHOT_I_DS = "createdSnapshotIDs"; + + @SerializedName(SERIALIZED_NAME_CREATED_SNAPSHOT_I_DS) + @javax.annotation.Nullable private List createdSnapshotIDs = new ArrayList<>(); + + public static final String SERIALIZED_NAME_KIND = "kind"; + + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nonnull + private String kind; + + public CreateSnapshotsResult() {} + + public CreateSnapshotsResult createdSnapshotIDs( + @javax.annotation.Nullable List createdSnapshotIDs) { + this.createdSnapshotIDs = createdSnapshotIDs; + return this; + } + + public CreateSnapshotsResult addCreatedSnapshotIDsItem(UUID createdSnapshotIDsItem) { + if (this.createdSnapshotIDs == null) { + this.createdSnapshotIDs = new ArrayList<>(); + } + this.createdSnapshotIDs.add(createdSnapshotIDsItem); + return this; + } + + /** + * Get createdSnapshotIDs + * + * @return createdSnapshotIDs + */ + @javax.annotation.Nullable public List getCreatedSnapshotIDs() { + return createdSnapshotIDs; + } + + public void setCreatedSnapshotIDs(@javax.annotation.Nullable List createdSnapshotIDs) { + this.createdSnapshotIDs = createdSnapshotIDs; + } + + public CreateSnapshotsResult kind(@javax.annotation.Nonnull String kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * + * @return kind + */ + @javax.annotation.Nonnull + public String getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nonnull String kind) { + this.kind = kind; + } + + /** + * 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 CreateSnapshotsResult instance itself + */ + public CreateSnapshotsResult 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; + } + CreateSnapshotsResult createSnapshotsResult = (CreateSnapshotsResult) o; + return Objects.equals(this.createdSnapshotIDs, createSnapshotsResult.createdSnapshotIDs) + && Objects.equals(this.kind, createSnapshotsResult.kind) + && Objects.equals( + this.additionalProperties, createSnapshotsResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdSnapshotIDs, kind, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateSnapshotsResult {\n"); + sb.append(" createdSnapshotIDs: ") + .append(toIndentedString(createdSnapshotIDs)) + .append("\n"); + sb.append(" kind: ").append(toIndentedString(kind)).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("createdSnapshotIDs", "kind")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("kind")); + } + + /** + * 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 CreateSnapshotsResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateSnapshotsResult.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 CreateSnapshotsResult is not found in the empty JSON string", + CreateSnapshotsResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateSnapshotsResult.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(); + // ensure the optional json data is an array if present + if (jsonObj.get("createdSnapshotIDs") != null + && !jsonObj.get("createdSnapshotIDs").isJsonNull() + && !jsonObj.get("createdSnapshotIDs").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `createdSnapshotIDs` to be an array in the JSON string but got `%s`", + jsonObj.get("createdSnapshotIDs").toString())); + } + if (!jsonObj.get("kind").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("kind").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSnapshotsResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSnapshotsResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateSnapshotsResult.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSnapshotsResult 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 CreateSnapshotsResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateSnapshotsResult 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 CreateSnapshotsResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSnapshotsResult + * @throws IOException if the JSON string is invalid with respect to CreateSnapshotsResult + */ + public static CreateSnapshotsResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSnapshotsResult.class); + } + + /** + * Convert an instance of CreateSnapshotsResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateVolumeAutomationPayload.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateVolumeAutomationPayload.java new file mode 100644 index 00000000..66999216 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/CreateVolumeAutomationPayload.java @@ -0,0 +1,444 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; +import java.util.UUID; + +/** CreateVolumeAutomationPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class CreateVolumeAutomationPayload { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_INPUT = "input"; + + @SerializedName(SERIALIZED_NAME_INPUT) + @javax.annotation.Nullable private VolumeAutomationInput input; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_TEMPLATE_ID = "templateId"; + + @SerializedName(SERIALIZED_NAME_TEMPLATE_ID) + @javax.annotation.Nonnull + private UUID templateId; + + public static final String SERIALIZED_NAME_TRIGGERS = "triggers"; + + @SerializedName(SERIALIZED_NAME_TRIGGERS) + @javax.annotation.Nullable private AutomationTriggers triggers; + + public CreateVolumeAutomationPayload() {} + + public CreateVolumeAutomationPayload description( + @javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Get description + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public CreateVolumeAutomationPayload input( + @javax.annotation.Nullable VolumeAutomationInput input) { + this.input = input; + return this; + } + + /** + * Get input + * + * @return input + */ + @javax.annotation.Nullable public VolumeAutomationInput getInput() { + return input; + } + + public void setInput(@javax.annotation.Nullable VolumeAutomationInput input) { + this.input = input; + } + + public CreateVolumeAutomationPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public CreateVolumeAutomationPayload templateId(@javax.annotation.Nonnull UUID templateId) { + this.templateId = templateId; + return this; + } + + /** + * Get templateId + * + * @return templateId + */ + @javax.annotation.Nonnull + public UUID getTemplateId() { + return templateId; + } + + public void setTemplateId(@javax.annotation.Nonnull UUID templateId) { + this.templateId = templateId; + } + + public CreateVolumeAutomationPayload triggers( + @javax.annotation.Nullable AutomationTriggers triggers) { + this.triggers = triggers; + return this; + } + + /** + * Get triggers + * + * @return triggers + */ + @javax.annotation.Nullable public AutomationTriggers getTriggers() { + return triggers; + } + + public void setTriggers(@javax.annotation.Nullable AutomationTriggers triggers) { + this.triggers = triggers; + } + + /** + * 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 CreateVolumeAutomationPayload instance itself + */ + public CreateVolumeAutomationPayload 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; + } + CreateVolumeAutomationPayload createVolumeAutomationPayload = + (CreateVolumeAutomationPayload) o; + return Objects.equals(this.description, createVolumeAutomationPayload.description) + && Objects.equals(this.input, createVolumeAutomationPayload.input) + && Objects.equals(this.name, createVolumeAutomationPayload.name) + && Objects.equals(this.templateId, createVolumeAutomationPayload.templateId) + && Objects.equals(this.triggers, createVolumeAutomationPayload.triggers) + && Objects.equals( + this.additionalProperties, + createVolumeAutomationPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, input, name, templateId, triggers, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateVolumeAutomationPayload {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" input: ").append(toIndentedString(input)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" triggers: ").append(toIndentedString(triggers)).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("description", "input", "name", "templateId", "triggers")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("templateId")); + } + + /** + * 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 + * CreateVolumeAutomationPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateVolumeAutomationPayload.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 CreateVolumeAutomationPayload is not found in the empty JSON string", + CreateVolumeAutomationPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateVolumeAutomationPayload.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("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + // validate the optional field `input` + if (jsonObj.get("input") != null && !jsonObj.get("input").isJsonNull()) { + VolumeAutomationInput.validateJsonElement(jsonObj.get("input")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (!jsonObj.get("templateId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `templateId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("templateId").toString())); + } + // validate the optional field `triggers` + if (jsonObj.get("triggers") != null && !jsonObj.get("triggers").isJsonNull()) { + AutomationTriggers.validateJsonElement(jsonObj.get("triggers")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateVolumeAutomationPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateVolumeAutomationPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateVolumeAutomationPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateVolumeAutomationPayload 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 CreateVolumeAutomationPayload read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateVolumeAutomationPayload 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 CreateVolumeAutomationPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateVolumeAutomationPayload + * @throws IOException if the JSON string is invalid with respect to + * CreateVolumeAutomationPayload + */ + public static CreateVolumeAutomationPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateVolumeAutomationPayload.class); + } + + /** + * Convert an instance of CreateVolumeAutomationPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorInfoDetail.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorInfoDetail.java new file mode 100644 index 00000000..699582cd --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorInfoDetail.java @@ -0,0 +1,406 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** ErrorInfoDetail */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ErrorInfoDetail { + public static final String SERIALIZED_NAME_AT_TYPE = "@type"; + + @SerializedName(SERIALIZED_NAME_AT_TYPE) + @javax.annotation.Nonnull + private String atType; + + public static final String SERIALIZED_NAME_DOMAIN = "domain"; + + @SerializedName(SERIALIZED_NAME_DOMAIN) + @javax.annotation.Nonnull + private String domain; + + public static final String SERIALIZED_NAME_METADATA = "metadata"; + + @SerializedName(SERIALIZED_NAME_METADATA) + @javax.annotation.Nullable private Map metadata = new HashMap<>(); + + public static final String SERIALIZED_NAME_REASON = "reason"; + + @SerializedName(SERIALIZED_NAME_REASON) + @javax.annotation.Nonnull + private String reason; + + public ErrorInfoDetail() {} + + public ErrorInfoDetail atType(@javax.annotation.Nonnull String atType) { + this.atType = atType; + return this; + } + + /** + * Get atType + * + * @return atType + */ + @javax.annotation.Nonnull + public String getAtType() { + return atType; + } + + public void setAtType(@javax.annotation.Nonnull String atType) { + this.atType = atType; + } + + public ErrorInfoDetail domain(@javax.annotation.Nonnull String domain) { + this.domain = domain; + return this; + } + + /** + * Get domain + * + * @return domain + */ + @javax.annotation.Nonnull + public String getDomain() { + return domain; + } + + public void setDomain(@javax.annotation.Nonnull String domain) { + this.domain = domain; + } + + public ErrorInfoDetail metadata(@javax.annotation.Nullable Map metadata) { + this.metadata = metadata; + return this; + } + + public ErrorInfoDetail putMetadataItem(String key, Object metadataItem) { + if (this.metadata == null) { + this.metadata = new HashMap<>(); + } + this.metadata.put(key, metadataItem); + return this; + } + + /** + * Get metadata + * + * @return metadata + */ + @javax.annotation.Nullable public Map getMetadata() { + return metadata; + } + + public void setMetadata(@javax.annotation.Nullable Map metadata) { + this.metadata = metadata; + } + + public ErrorInfoDetail reason(@javax.annotation.Nonnull String reason) { + this.reason = reason; + return this; + } + + /** + * Get reason + * + * @return reason + */ + @javax.annotation.Nonnull + public String getReason() { + return reason; + } + + public void setReason(@javax.annotation.Nonnull String reason) { + this.reason = reason; + } + + /** + * 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 ErrorInfoDetail instance itself + */ + public ErrorInfoDetail 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; + } + ErrorInfoDetail errorInfoDetail = (ErrorInfoDetail) o; + return Objects.equals(this.atType, errorInfoDetail.atType) + && Objects.equals(this.domain, errorInfoDetail.domain) + && Objects.equals(this.metadata, errorInfoDetail.metadata) + && Objects.equals(this.reason, errorInfoDetail.reason) + && Objects.equals(this.additionalProperties, errorInfoDetail.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(atType, domain, metadata, reason, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorInfoDetail {\n"); + sb.append(" atType: ").append(toIndentedString(atType)).append("\n"); + sb.append(" domain: ").append(toIndentedString(domain)).append("\n"); + sb.append(" metadata: ").append(toIndentedString(metadata)).append("\n"); + sb.append(" reason: ").append(toIndentedString(reason)).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("@type", "domain", "metadata", "reason")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("@type", "domain", "reason")); + } + + /** + * 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 ErrorInfoDetail + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorInfoDetail.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 ErrorInfoDetail is not found in the empty JSON string", + ErrorInfoDetail.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorInfoDetail.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("@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())); + } + if (!jsonObj.get("domain").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `domain` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("domain").toString())); + } + if (!jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `reason` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("reason").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorInfoDetail.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorInfoDetail' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ErrorInfoDetail.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorInfoDetail 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 ErrorInfoDetail read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorInfoDetail 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 ErrorInfoDetail given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorInfoDetail + * @throws IOException if the JSON string is invalid with respect to ErrorInfoDetail + */ + public static ErrorInfoDetail fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorInfoDetail.class); + } + + /** + * Convert an instance of ErrorInfoDetail to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponse.java new file mode 100644 index 00000000..b1608581 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponse.java @@ -0,0 +1,299 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** ErrorResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ErrorResponse { + public static final String SERIALIZED_NAME_ERROR = "error"; + + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nonnull + private ErrorResponseContent error; + + public ErrorResponse() {} + + public ErrorResponse error(@javax.annotation.Nonnull ErrorResponseContent error) { + this.error = error; + return this; + } + + /** + * Get error + * + * @return error + */ + @javax.annotation.Nonnull + public ErrorResponseContent getError() { + return error; + } + + public void setError(@javax.annotation.Nonnull ErrorResponseContent error) { + this.error = error; + } + + /** + * 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 ErrorResponse instance itself + */ + public ErrorResponse 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; + } + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.error, errorResponse.error) + && Objects.equals(this.additionalProperties, errorResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(error, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\n"); + sb.append(" error: ").append(toIndentedString(error)).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")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("error")); + } + + /** + * 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 ErrorResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponse.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 ErrorResponse is not found in the empty JSON string", + ErrorResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponse.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(); + // validate the required field `error` + ErrorResponseContent.validateJsonElement(jsonObj.get("error")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ErrorResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponse 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 ErrorResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorResponse 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 ErrorResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponse + * @throws IOException if the JSON string is invalid with respect to ErrorResponse + */ + public static ErrorResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponse.class); + } + + /** + * Convert an instance of ErrorResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContent.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContent.java new file mode 100644 index 00000000..bbb8099b --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContent.java @@ -0,0 +1,422 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.v1betaapi.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** ErrorResponseContent */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ErrorResponseContent { + public static final String SERIALIZED_NAME_CODE = "code"; + + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nonnull + private Integer code; + + public static final String SERIALIZED_NAME_DETAILS = "details"; + + @SerializedName(SERIALIZED_NAME_DETAILS) + @javax.annotation.Nullable private List details = new ArrayList<>(); + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nonnull + private String message; + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private String status; + + public ErrorResponseContent() {} + + public ErrorResponseContent code(@javax.annotation.Nonnull Integer code) { + this.code = code; + return this; + } + + /** + * Get code + * + * @return code + */ + @javax.annotation.Nonnull + public Integer getCode() { + return code; + } + + public void setCode(@javax.annotation.Nonnull Integer code) { + this.code = code; + } + + public ErrorResponseContent details( + @javax.annotation.Nullable List details) { + this.details = details; + return this; + } + + public ErrorResponseContent addDetailsItem(ErrorResponseContentDetails detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * Get details + * + * @return details + */ + @javax.annotation.Nullable public List getDetails() { + return details; + } + + public void setDetails(@javax.annotation.Nullable List details) { + this.details = details; + } + + public ErrorResponseContent message(@javax.annotation.Nonnull String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nonnull String message) { + this.message = message; + } + + public ErrorResponseContent status(@javax.annotation.Nonnull String status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nonnull + public String getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull String status) { + this.status = status; + } + + /** + * 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 ErrorResponseContent instance itself + */ + public ErrorResponseContent 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; + } + ErrorResponseContent errorResponseContent = (ErrorResponseContent) o; + return Objects.equals(this.code, errorResponseContent.code) + && Objects.equals(this.details, errorResponseContent.details) + && Objects.equals(this.message, errorResponseContent.message) + && Objects.equals(this.status, errorResponseContent.status) + && Objects.equals( + this.additionalProperties, errorResponseContent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, details, message, status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponseContent {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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("code", "details", "message", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("code", "message", "status")); + } + + /** + * 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 ErrorResponseContent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponseContent.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 ErrorResponseContent is not found in the empty JSON string", + ErrorResponseContent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponseContent.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("details") != null && !jsonObj.get("details").isJsonNull()) { + JsonArray jsonArraydetails = jsonObj.getAsJsonArray("details"); + if (jsonArraydetails != null) { + // ensure the json data is an array + if (!jsonObj.get("details").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `details` to be an array in the JSON string but got `%s`", + jsonObj.get("details").toString())); + } + + // validate the optional field `details` (array) + for (int i = 0; i < jsonArraydetails.size(); i++) { + ErrorResponseContentDetails.validateJsonElement(jsonArraydetails.get(i)); + } + ; + } + } + if (!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("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `status` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("status").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponseContent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponseContent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ErrorResponseContent.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponseContent 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 ErrorResponseContent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorResponseContent 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 ErrorResponseContent given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponseContent + * @throws IOException if the JSON string is invalid with respect to ErrorResponseContent + */ + public static ErrorResponseContent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponseContent.class); + } + + /** + * Convert an instance of ErrorResponseContent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContentDetails.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContentDetails.java new file mode 100644 index 00000000..10e287bd --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ErrorResponseContentDetails.java @@ -0,0 +1,350 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.v1betaapi.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +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.ArrayList; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ErrorResponseContentDetails extends AbstractOpenApiSchema { + private static final Logger log = Logger.getLogger(ErrorResponseContentDetails.class.getName()); + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponseContentDetails.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponseContentDetails' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter adapterErrorInfoDetail = + gson.getDelegateAdapter(this, TypeToken.get(ErrorInfoDetail.class)); + final TypeAdapter adapterLocalizedMessageErrorDetail = + gson.getDelegateAdapter(this, TypeToken.get(LocalizedMessageErrorDetail.class)); + final TypeAdapter adapterHelpErrorDetail = + gson.getDelegateAdapter(this, TypeToken.get(HelpErrorDetail.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponseContentDetails value) + throws IOException { + if (value == null || value.getActualInstance() == null) { + elementAdapter.write(out, null); + return; + } + + // check if the actual instance is of the type `ErrorInfoDetail` + if (value.getActualInstance() instanceof ErrorInfoDetail) { + JsonElement element = + adapterErrorInfoDetail.toJsonTree( + (ErrorInfoDetail) value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type + // `LocalizedMessageErrorDetail` + if (value.getActualInstance() instanceof LocalizedMessageErrorDetail) { + JsonElement element = + adapterLocalizedMessageErrorDetail.toJsonTree( + (LocalizedMessageErrorDetail) + value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + // check if the actual instance is of the type `HelpErrorDetail` + if (value.getActualInstance() instanceof HelpErrorDetail) { + JsonElement element = + adapterHelpErrorDetail.toJsonTree( + (HelpErrorDetail) value.getActualInstance()); + elementAdapter.write(out, element); + return; + } + throw new IOException( + "Failed to serialize as the type doesn't match oneOf schemas: ErrorInfoDetail, HelpErrorDetail, LocalizedMessageErrorDetail"); + } + + @Override + public ErrorResponseContentDetails read(JsonReader in) throws IOException { + Object deserialized = null; + JsonElement jsonElement = elementAdapter.read(in); + + int match = 0; + ArrayList errorMessages = new ArrayList<>(); + TypeAdapter actualAdapter = elementAdapter; + + // deserialize ErrorInfoDetail + try { + // validate the JSON object to see if any exception is thrown + ErrorInfoDetail.validateJsonElement(jsonElement); + actualAdapter = adapterErrorInfoDetail; + match++; + log.log(Level.FINER, "Input data matches schema 'ErrorInfoDetail'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for ErrorInfoDetail failed with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema 'ErrorInfoDetail'", + e); + } + // deserialize LocalizedMessageErrorDetail + try { + // validate the JSON object to see if any exception is thrown + LocalizedMessageErrorDetail.validateJsonElement(jsonElement); + actualAdapter = adapterLocalizedMessageErrorDetail; + match++; + log.log( + Level.FINER, + "Input data matches schema 'LocalizedMessageErrorDetail'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for LocalizedMessageErrorDetail failed with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema 'LocalizedMessageErrorDetail'", + e); + } + // deserialize HelpErrorDetail + try { + // validate the JSON object to see if any exception is thrown + HelpErrorDetail.validateJsonElement(jsonElement); + actualAdapter = adapterHelpErrorDetail; + match++; + log.log(Level.FINER, "Input data matches schema 'HelpErrorDetail'"); + } catch (Exception e) { + // deserialization failed, continue + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for HelpErrorDetail failed with `%s`.", + e.getMessage())); + log.log( + Level.FINER, + "Input data does not match schema 'HelpErrorDetail'", + e); + } + + if (match == 1) { + ErrorResponseContentDetails ret = new ErrorResponseContentDetails(); + ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement)); + return ret; + } + + throw new IOException( + String.format( + java.util.Locale.ROOT, + "Failed deserialization for ErrorResponseContentDetails: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", + match, + errorMessages, + jsonElement.toString())); + } + }.nullSafe(); + } + } + + // store a list of schema names defined in oneOf + public static final Map> schemas = new HashMap>(); + + public ErrorResponseContentDetails() { + super("oneOf", Boolean.FALSE); + } + + public ErrorResponseContentDetails(Object o) { + super("oneOf", Boolean.FALSE); + setActualInstance(o); + } + + static { + schemas.put("ErrorInfoDetail", ErrorInfoDetail.class); + schemas.put("LocalizedMessageErrorDetail", LocalizedMessageErrorDetail.class); + schemas.put("HelpErrorDetail", HelpErrorDetail.class); + } + + @Override + public Map> getSchemas() { + return ErrorResponseContentDetails.schemas; + } + + /** + * Set the instance that matches the oneOf child schema, check the instance parameter is valid + * against the oneOf child schemas: ErrorInfoDetail, HelpErrorDetail, + * LocalizedMessageErrorDetail + * + *

It could be an instance of the 'oneOf' schemas. + */ + @Override + public void setActualInstance(Object instance) { + if (instance instanceof ErrorInfoDetail) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof LocalizedMessageErrorDetail) { + super.setActualInstance(instance); + return; + } + + if (instance instanceof HelpErrorDetail) { + super.setActualInstance(instance); + return; + } + + throw new RuntimeException( + "Invalid instance type. Must be ErrorInfoDetail, HelpErrorDetail, LocalizedMessageErrorDetail"); + } + + /** + * Get the actual instance, which can be the following: ErrorInfoDetail, HelpErrorDetail, + * LocalizedMessageErrorDetail + * + * @return The actual instance (ErrorInfoDetail, HelpErrorDetail, LocalizedMessageErrorDetail) + */ + @SuppressWarnings("unchecked") + @Override + public Object getActualInstance() { + return super.getActualInstance(); + } + + /** + * Get the actual instance of `ErrorInfoDetail`. If the actual instance is not + * `ErrorInfoDetail`, the ClassCastException will be thrown. + * + * @return The actual instance of `ErrorInfoDetail` + * @throws ClassCastException if the instance is not `ErrorInfoDetail` + */ + public ErrorInfoDetail getErrorInfoDetail() throws ClassCastException { + return (ErrorInfoDetail) super.getActualInstance(); + } + + /** + * Get the actual instance of `LocalizedMessageErrorDetail`. If the actual instance is not + * `LocalizedMessageErrorDetail`, the ClassCastException will be thrown. + * + * @return The actual instance of `LocalizedMessageErrorDetail` + * @throws ClassCastException if the instance is not `LocalizedMessageErrorDetail` + */ + public LocalizedMessageErrorDetail getLocalizedMessageErrorDetail() throws ClassCastException { + return (LocalizedMessageErrorDetail) super.getActualInstance(); + } + + /** + * Get the actual instance of `HelpErrorDetail`. If the actual instance is not + * `HelpErrorDetail`, the ClassCastException will be thrown. + * + * @return The actual instance of `HelpErrorDetail` + * @throws ClassCastException if the instance is not `HelpErrorDetail` + */ + public HelpErrorDetail getHelpErrorDetail() throws ClassCastException { + return (HelpErrorDetail) super.getActualInstance(); + } + + /** + * 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 + * ErrorResponseContentDetails + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + // validate oneOf schemas one by one + int validCount = 0; + ArrayList errorMessages = new ArrayList<>(); + // validate the json string with ErrorInfoDetail + try { + ErrorInfoDetail.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for ErrorInfoDetail failed with `%s`.", + e.getMessage())); + // continue to the next one + } + // validate the json string with LocalizedMessageErrorDetail + try { + LocalizedMessageErrorDetail.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for LocalizedMessageErrorDetail failed with `%s`.", + e.getMessage())); + // continue to the next one + } + // validate the json string with HelpErrorDetail + try { + HelpErrorDetail.validateJsonElement(jsonElement); + validCount++; + } catch (Exception e) { + errorMessages.add( + String.format( + java.util.Locale.ROOT, + "Deserialization for HelpErrorDetail failed with `%s`.", + e.getMessage())); + // continue to the next one + } + if (validCount != 1) { + throw new IOException( + String.format( + java.util.Locale.ROOT, + "The JSON string is invalid for ErrorResponseContentDetails with oneOf schemas: ErrorInfoDetail, HelpErrorDetail, LocalizedMessageErrorDetail. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", + validCount, + errorMessages, + jsonElement.toString())); + } + } + + /** + * Create an instance of ErrorResponseContentDetails given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponseContentDetails + * @throws IOException if the JSON string is invalid with respect to ErrorResponseContentDetails + */ + public static ErrorResponseContentDetails fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponseContentDetails.class); + } + + /** + * Convert an instance of ErrorResponseContentDetails to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/EventCreateResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/EventCreateResponse.java new file mode 100644 index 00000000..01ec61e3 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/EventCreateResponse.java @@ -0,0 +1,306 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** EventCreateResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class EventCreateResponse { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private String id; + + public EventCreateResponse() {} + + public EventCreateResponse id(@javax.annotation.Nonnull String id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull String id) { + this.id = id; + } + + /** + * 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 EventCreateResponse instance itself + */ + public EventCreateResponse 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; + } + EventCreateResponse eventCreateResponse = (EventCreateResponse) o; + return Objects.equals(this.id, eventCreateResponse.id) + && Objects.equals( + this.additionalProperties, eventCreateResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EventCreateResponse {\n"); + sb.append(" id: ").append(toIndentedString(id)).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("id")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("id")); + } + + /** + * 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 EventCreateResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EventCreateResponse.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 EventCreateResponse is not found in the empty JSON string", + EventCreateResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EventCreateResponse.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("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EventCreateResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EventCreateResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(EventCreateResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, EventCreateResponse 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 EventCreateResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EventCreateResponse 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 EventCreateResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of EventCreateResponse + * @throws IOException if the JSON string is invalid with respect to EventCreateResponse + */ + public static EventCreateResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EventCreateResponse.class); + } + + /** + * Convert an instance of EventCreateResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeIDsResult.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeIDsResult.java new file mode 100644 index 00000000..365e4a20 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeIDsResult.java @@ -0,0 +1,351 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** GetVolumeIDsResult */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class GetVolumeIDsResult { + public static final String SERIALIZED_NAME_KIND = "kind"; + + @SerializedName(SERIALIZED_NAME_KIND) + @javax.annotation.Nonnull + private String kind; + + public static final String SERIALIZED_NAME_VOLUME_I_DS = "volumeIDs"; + + @SerializedName(SERIALIZED_NAME_VOLUME_I_DS) + @javax.annotation.Nullable private List volumeIDs = new ArrayList<>(); + + public GetVolumeIDsResult() {} + + public GetVolumeIDsResult kind(@javax.annotation.Nonnull String kind) { + this.kind = kind; + return this; + } + + /** + * Get kind + * + * @return kind + */ + @javax.annotation.Nonnull + public String getKind() { + return kind; + } + + public void setKind(@javax.annotation.Nonnull String kind) { + this.kind = kind; + } + + public GetVolumeIDsResult volumeIDs(@javax.annotation.Nullable List volumeIDs) { + this.volumeIDs = volumeIDs; + return this; + } + + public GetVolumeIDsResult addVolumeIDsItem(UUID volumeIDsItem) { + if (this.volumeIDs == null) { + this.volumeIDs = new ArrayList<>(); + } + this.volumeIDs.add(volumeIDsItem); + return this; + } + + /** + * Get volumeIDs + * + * @return volumeIDs + */ + @javax.annotation.Nullable public List getVolumeIDs() { + return volumeIDs; + } + + public void setVolumeIDs(@javax.annotation.Nullable List volumeIDs) { + this.volumeIDs = volumeIDs; + } + + /** + * 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 GetVolumeIDsResult instance itself + */ + public GetVolumeIDsResult 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; + } + GetVolumeIDsResult getVolumeIDsResult = (GetVolumeIDsResult) o; + return Objects.equals(this.kind, getVolumeIDsResult.kind) + && Objects.equals(this.volumeIDs, getVolumeIDsResult.volumeIDs) + && Objects.equals( + this.additionalProperties, getVolumeIDsResult.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(kind, volumeIDs, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetVolumeIDsResult {\n"); + sb.append(" kind: ").append(toIndentedString(kind)).append("\n"); + sb.append(" volumeIDs: ").append(toIndentedString(volumeIDs)).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("kind", "volumeIDs")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("kind")); + } + + /** + * 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 GetVolumeIDsResult + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetVolumeIDsResult.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 GetVolumeIDsResult is not found in the empty JSON string", + GetVolumeIDsResult.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetVolumeIDsResult.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("kind").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `kind` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("kind").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("volumeIDs") != null + && !jsonObj.get("volumeIDs").isJsonNull() + && !jsonObj.get("volumeIDs").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `volumeIDs` to be an array in the JSON string but got `%s`", + jsonObj.get("volumeIDs").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetVolumeIDsResult.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetVolumeIDsResult' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetVolumeIDsResult.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetVolumeIDsResult 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 GetVolumeIDsResult read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetVolumeIDsResult 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 GetVolumeIDsResult given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetVolumeIDsResult + * @throws IOException if the JSON string is invalid with respect to GetVolumeIDsResult + */ + public static GetVolumeIDsResult fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetVolumeIDsResult.class); + } + + /** + * Convert an instance of GetVolumeIDsResult to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeTemplateResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeTemplateResponse.java new file mode 100644 index 00000000..37015301 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/GetVolumeTemplateResponse.java @@ -0,0 +1,467 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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.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; + +/** GetVolumeTemplateResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class GetVolumeTemplateResponse { + public static final String SERIALIZED_NAME_CREATE_TIME = "createTime"; + + @SerializedName(SERIALIZED_NAME_CREATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime createTime; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private String id; + + public static final String SERIALIZED_NAME_INPUT = "input"; + + @SerializedName(SERIALIZED_NAME_INPUT) + @javax.annotation.Nullable private VolumeTemplateAutomationInput input; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_OUTPUT = "output"; + + @SerializedName(SERIALIZED_NAME_OUTPUT) + @javax.annotation.Nullable private VolumeOutput output; + + public GetVolumeTemplateResponse() {} + + public GetVolumeTemplateResponse createTime( + @javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + return this; + } + + /** + * Get createTime + * + * @return createTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(@javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + } + + public GetVolumeTemplateResponse description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Get description + * + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + public GetVolumeTemplateResponse id(@javax.annotation.Nonnull String id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @javax.annotation.Nonnull + public String getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull String id) { + this.id = id; + } + + public GetVolumeTemplateResponse input( + @javax.annotation.Nullable VolumeTemplateAutomationInput input) { + this.input = input; + return this; + } + + /** + * Get input + * + * @return input + */ + @javax.annotation.Nullable public VolumeTemplateAutomationInput getInput() { + return input; + } + + public void setInput(@javax.annotation.Nullable VolumeTemplateAutomationInput input) { + this.input = input; + } + + public GetVolumeTemplateResponse name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + public GetVolumeTemplateResponse output(@javax.annotation.Nullable VolumeOutput output) { + this.output = output; + return this; + } + + /** + * Get output + * + * @return output + */ + @javax.annotation.Nullable public VolumeOutput getOutput() { + return output; + } + + public void setOutput(@javax.annotation.Nullable VolumeOutput output) { + this.output = output; + } + + /** + * 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 GetVolumeTemplateResponse instance itself + */ + public GetVolumeTemplateResponse 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; + } + GetVolumeTemplateResponse getVolumeTemplateResponse = (GetVolumeTemplateResponse) o; + return Objects.equals(this.createTime, getVolumeTemplateResponse.createTime) + && Objects.equals(this.description, getVolumeTemplateResponse.description) + && Objects.equals(this.id, getVolumeTemplateResponse.id) + && Objects.equals(this.input, getVolumeTemplateResponse.input) + && Objects.equals(this.name, getVolumeTemplateResponse.name) + && Objects.equals(this.output, getVolumeTemplateResponse.output) + && Objects.equals( + this.additionalProperties, getVolumeTemplateResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createTime, description, id, input, name, output, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetVolumeTemplateResponse {\n"); + sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" input: ").append(toIndentedString(input)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" output: ").append(toIndentedString(output)).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( + "createTime", "description", "id", "input", "name", "output")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet(Arrays.asList("createTime", "description", "id", "name")); + } + + /** + * 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 GetVolumeTemplateResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetVolumeTemplateResponse.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 GetVolumeTemplateResponse is not found in the empty JSON string", + GetVolumeTemplateResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetVolumeTemplateResponse.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("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + // validate the optional field `input` + if (jsonObj.get("input") != null && !jsonObj.get("input").isJsonNull()) { + VolumeTemplateAutomationInput.validateJsonElement(jsonObj.get("input")); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + // validate the optional field `output` + if (jsonObj.get("output") != null && !jsonObj.get("output").isJsonNull()) { + VolumeOutput.validateJsonElement(jsonObj.get("output")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetVolumeTemplateResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetVolumeTemplateResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetVolumeTemplateResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetVolumeTemplateResponse 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 GetVolumeTemplateResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetVolumeTemplateResponse 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 GetVolumeTemplateResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetVolumeTemplateResponse + * @throws IOException if the JSON string is invalid with respect to GetVolumeTemplateResponse + */ + public static GetVolumeTemplateResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetVolumeTemplateResponse.class); + } + + /** + * Convert an instance of GetVolumeTemplateResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/HelpErrorDetail.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/HelpErrorDetail.java new file mode 100644 index 00000000..000e33b8 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/HelpErrorDetail.java @@ -0,0 +1,373 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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; + +/** HelpErrorDetail */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class HelpErrorDetail { + public static final String SERIALIZED_NAME_AT_TYPE = "@type"; + + @SerializedName(SERIALIZED_NAME_AT_TYPE) + @javax.annotation.Nonnull + private String atType; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_URL = "url"; + + @SerializedName(SERIALIZED_NAME_URL) + @javax.annotation.Nonnull + private String url; + + public HelpErrorDetail() {} + + public HelpErrorDetail atType(@javax.annotation.Nonnull String atType) { + this.atType = atType; + return this; + } + + /** + * Get atType + * + * @return atType + */ + @javax.annotation.Nonnull + public String getAtType() { + return atType; + } + + public void setAtType(@javax.annotation.Nonnull String atType) { + this.atType = atType; + } + + public HelpErrorDetail description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * Get description + * + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + public HelpErrorDetail url(@javax.annotation.Nonnull String url) { + this.url = url; + return this; + } + + /** + * Get url + * + * @return url + */ + @javax.annotation.Nonnull + public String getUrl() { + return url; + } + + public void setUrl(@javax.annotation.Nonnull String url) { + this.url = url; + } + + /** + * 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 HelpErrorDetail instance itself + */ + public HelpErrorDetail 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; + } + HelpErrorDetail helpErrorDetail = (HelpErrorDetail) o; + return Objects.equals(this.atType, helpErrorDetail.atType) + && Objects.equals(this.description, helpErrorDetail.description) + && Objects.equals(this.url, helpErrorDetail.url) + && Objects.equals(this.additionalProperties, helpErrorDetail.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(atType, description, url, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HelpErrorDetail {\n"); + sb.append(" atType: ").append(toIndentedString(atType)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" url: ").append(toIndentedString(url)).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("@type", "description", "url")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("@type", "description", "url")); + } + + /** + * 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 HelpErrorDetail + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!HelpErrorDetail.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 HelpErrorDetail is not found in the empty JSON string", + HelpErrorDetail.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HelpErrorDetail.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("@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())); + } + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("url").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `url` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HelpErrorDetail.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HelpErrorDetail' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(HelpErrorDetail.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, HelpErrorDetail 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 HelpErrorDetail read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HelpErrorDetail 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 HelpErrorDetail given an JSON string + * + * @param jsonString JSON string + * @return An instance of HelpErrorDetail + * @throws IOException if the JSON string is invalid with respect to HelpErrorDetail + */ + public static HelpErrorDetail fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HelpErrorDetail.class); + } + + /** + * Convert an instance of HelpErrorDetail to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsItem.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsItem.java new file mode 100644 index 00000000..0016d810 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsItem.java @@ -0,0 +1,508 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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.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; +import java.util.UUID; + +/** ListAutomationsItem */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ListAutomationsItem { + public static final String SERIALIZED_NAME_CREATE_TIME = "createTime"; + + @SerializedName(SERIALIZED_NAME_CREATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime createTime; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_TEMPLATE_ID = "templateId"; + + @SerializedName(SERIALIZED_NAME_TEMPLATE_ID) + @javax.annotation.Nullable private UUID templateId; + + public static final String SERIALIZED_NAME_TRIGGERS = "triggers"; + + @SerializedName(SERIALIZED_NAME_TRIGGERS) + @javax.annotation.Nullable private AutomationTriggers triggers; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public ListAutomationsItem() {} + + public ListAutomationsItem createTime(@javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + return this; + } + + /** + * Get createTime + * + * @return createTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(@javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + } + + public ListAutomationsItem description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Get description + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public ListAutomationsItem id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public ListAutomationsItem name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public ListAutomationsItem templateId(@javax.annotation.Nullable UUID templateId) { + this.templateId = templateId; + return this; + } + + /** + * Get templateId + * + * @return templateId + */ + @javax.annotation.Nullable public UUID getTemplateId() { + return templateId; + } + + public void setTemplateId(@javax.annotation.Nullable UUID templateId) { + this.templateId = templateId; + } + + public ListAutomationsItem triggers(@javax.annotation.Nullable AutomationTriggers triggers) { + this.triggers = triggers; + return this; + } + + /** + * Get triggers + * + * @return triggers + */ + @javax.annotation.Nullable public AutomationTriggers getTriggers() { + return triggers; + } + + public void setTriggers(@javax.annotation.Nullable AutomationTriggers triggers) { + this.triggers = triggers; + } + + public ListAutomationsItem updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Get updateTime + * + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + /** + * 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 ListAutomationsItem instance itself + */ + public ListAutomationsItem 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; + } + ListAutomationsItem listAutomationsItem = (ListAutomationsItem) o; + return Objects.equals(this.createTime, listAutomationsItem.createTime) + && Objects.equals(this.description, listAutomationsItem.description) + && Objects.equals(this.id, listAutomationsItem.id) + && Objects.equals(this.name, listAutomationsItem.name) + && Objects.equals(this.templateId, listAutomationsItem.templateId) + && Objects.equals(this.triggers, listAutomationsItem.triggers) + && Objects.equals(this.updateTime, listAutomationsItem.updateTime) + && Objects.equals( + this.additionalProperties, listAutomationsItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createTime, + description, + id, + name, + templateId, + triggers, + updateTime, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListAutomationsItem {\n"); + sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" templateId: ").append(toIndentedString(templateId)).append("\n"); + sb.append(" triggers: ").append(toIndentedString(triggers)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).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( + "createTime", + "description", + "id", + "name", + "templateId", + "triggers", + "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet(Arrays.asList("createTime", "id", "updateTime")); + } + + /** + * 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 ListAutomationsItem + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListAutomationsItem.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 ListAutomationsItem is not found in the empty JSON string", + ListAutomationsItem.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListAutomationsItem.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("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("templateId") != null && !jsonObj.get("templateId").isJsonNull()) + && !jsonObj.get("templateId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `templateId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("templateId").toString())); + } + // validate the optional field `triggers` + if (jsonObj.get("triggers") != null && !jsonObj.get("triggers").isJsonNull()) { + AutomationTriggers.validateJsonElement(jsonObj.get("triggers")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListAutomationsItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListAutomationsItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListAutomationsItem.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListAutomationsItem 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 ListAutomationsItem read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAutomationsItem 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 ListAutomationsItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListAutomationsItem + * @throws IOException if the JSON string is invalid with respect to ListAutomationsItem + */ + public static ListAutomationsItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListAutomationsItem.class); + } + + /** + * Convert an instance of ListAutomationsItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsResponse.java new file mode 100644 index 00000000..3c5e6ea5 --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListAutomationsResponse.java @@ -0,0 +1,360 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.v1betaapi.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** ListAutomationsResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ListAutomationsResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NEXT_PAGE_TOKEN = "nextPageToken"; + + @SerializedName(SERIALIZED_NAME_NEXT_PAGE_TOKEN) + @javax.annotation.Nullable private String nextPageToken; + + public ListAutomationsResponse() {} + + public ListAutomationsResponse items( + @javax.annotation.Nonnull List items) { + this.items = items; + return this; + } + + public ListAutomationsResponse addItemsItem(ListAutomationsItem itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * + * @return items + */ + @javax.annotation.Nonnull + public List getItems() { + return items; + } + + public void setItems(@javax.annotation.Nonnull List items) { + this.items = items; + } + + public ListAutomationsResponse nextPageToken(@javax.annotation.Nullable String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + /** + * A token that can be sent as `page_token` to retrieve the next page. If this field + * is omitted, there are no subsequent pages. + * + * @return nextPageToken + */ + @javax.annotation.Nullable public String getNextPageToken() { + return nextPageToken; + } + + public void setNextPageToken(@javax.annotation.Nullable String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * 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 ListAutomationsResponse instance itself + */ + public ListAutomationsResponse 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; + } + ListAutomationsResponse listAutomationsResponse = (ListAutomationsResponse) o; + return Objects.equals(this.items, listAutomationsResponse.items) + && Objects.equals(this.nextPageToken, listAutomationsResponse.nextPageToken) + && Objects.equals( + this.additionalProperties, listAutomationsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(items, nextPageToken, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListAutomationsResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" nextPageToken: ").append(toIndentedString(nextPageToken)).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("items", "nextPageToken")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("items")); + } + + /** + * 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 ListAutomationsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListAutomationsResponse.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 ListAutomationsResponse is not found in the empty JSON string", + ListAutomationsResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListAutomationsResponse.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(); + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `items` to be an array in the JSON string but got `%s`", + jsonObj.get("items").toString())); + } + + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + ListAutomationsItem.validateJsonElement(jsonArrayitems.get(i)); + } + ; + if ((jsonObj.get("nextPageToken") != null && !jsonObj.get("nextPageToken").isJsonNull()) + && !jsonObj.get("nextPageToken").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `nextPageToken` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("nextPageToken").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListAutomationsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListAutomationsResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListAutomationsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListAutomationsResponse 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 ListAutomationsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListAutomationsResponse 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 ListAutomationsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListAutomationsResponse + * @throws IOException if the JSON string is invalid with respect to ListAutomationsResponse + */ + public static ListAutomationsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListAutomationsResponse.class); + } + + /** + * Convert an instance of ListAutomationsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsItem.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsItem.java new file mode 100644 index 00000000..321d1a0d --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsItem.java @@ -0,0 +1,456 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.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.JsonAdapter; +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; +import java.util.UUID; + +/** ListExecutionsItem */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ListExecutionsItem { + public static final String SERIALIZED_NAME_CREATE_TIME = "createTime"; + + @SerializedName(SERIALIZED_NAME_CREATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime createTime; + + public static final String SERIALIZED_NAME_END_TIME = "endTime"; + + @SerializedName(SERIALIZED_NAME_END_TIME) + @javax.annotation.Nullable private OffsetDateTime endTime; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + /** Gets or Sets status */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + PENDING("PENDING"), + + RUNNING("RUNNING"), + + COMPLETED("COMPLETED"), + + FAILED("FAILED"), + + TERMINATED("TERMINATED"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private StatusEnum status; + + public ListExecutionsItem() {} + + public ListExecutionsItem createTime(@javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + return this; + } + + /** + * Get createTime + * + * @return createTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreateTime() { + return createTime; + } + + public void setCreateTime(@javax.annotation.Nonnull OffsetDateTime createTime) { + this.createTime = createTime; + } + + public ListExecutionsItem endTime(@javax.annotation.Nullable OffsetDateTime endTime) { + this.endTime = endTime; + return this; + } + + /** + * Get endTime + * + * @return endTime + */ + @javax.annotation.Nullable public OffsetDateTime getEndTime() { + return endTime; + } + + public void setEndTime(@javax.annotation.Nullable OffsetDateTime endTime) { + this.endTime = endTime; + } + + public ListExecutionsItem id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Get id + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public ListExecutionsItem status(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nonnull + public StatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull StatusEnum status) { + this.status = status; + } + + /** + * 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 ListExecutionsItem instance itself + */ + public ListExecutionsItem 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; + } + ListExecutionsItem listExecutionsItem = (ListExecutionsItem) o; + return Objects.equals(this.createTime, listExecutionsItem.createTime) + && Objects.equals(this.endTime, listExecutionsItem.endTime) + && Objects.equals(this.id, listExecutionsItem.id) + && Objects.equals(this.status, listExecutionsItem.status) + && Objects.equals( + this.additionalProperties, listExecutionsItem.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createTime, endTime, id, status, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListExecutionsItem {\n"); + sb.append(" createTime: ").append(toIndentedString(createTime)).append("\n"); + sb.append(" endTime: ").append(toIndentedString(endTime)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).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("createTime", "endTime", "id", "status")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("createTime", "id", "status")); + } + + /** + * 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 ListExecutionsItem + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListExecutionsItem.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 ListExecutionsItem is not found in the empty JSON string", + ListExecutionsItem.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListExecutionsItem.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("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if (!jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `status` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("status").toString())); + } + // validate the required field `status` + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListExecutionsItem.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListExecutionsItem' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListExecutionsItem.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListExecutionsItem 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 ListExecutionsItem read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListExecutionsItem 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 ListExecutionsItem given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListExecutionsItem + * @throws IOException if the JSON string is invalid with respect to ListExecutionsItem + */ + public static ListExecutionsItem fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListExecutionsItem.class); + } + + /** + * Convert an instance of ListExecutionsItem to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsResponse.java new file mode 100644 index 00000000..cf79387a --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListExecutionsResponse.java @@ -0,0 +1,358 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.v1betaapi.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** ListExecutionsResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ListExecutionsResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NEXT_PAGE_TOKEN = "nextPageToken"; + + @SerializedName(SERIALIZED_NAME_NEXT_PAGE_TOKEN) + @javax.annotation.Nullable private String nextPageToken; + + public ListExecutionsResponse() {} + + public ListExecutionsResponse items(@javax.annotation.Nonnull List items) { + this.items = items; + return this; + } + + public ListExecutionsResponse addItemsItem(ListExecutionsItem itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * + * @return items + */ + @javax.annotation.Nonnull + public List getItems() { + return items; + } + + public void setItems(@javax.annotation.Nonnull List items) { + this.items = items; + } + + public ListExecutionsResponse nextPageToken(@javax.annotation.Nullable String nextPageToken) { + this.nextPageToken = nextPageToken; + return this; + } + + /** + * A token that can be sent as `page_token` to retrieve the next page. If this field + * is omitted, there are no subsequent pages. + * + * @return nextPageToken + */ + @javax.annotation.Nullable public String getNextPageToken() { + return nextPageToken; + } + + public void setNextPageToken(@javax.annotation.Nullable String nextPageToken) { + this.nextPageToken = nextPageToken; + } + + /** + * 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 ListExecutionsResponse instance itself + */ + public ListExecutionsResponse 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; + } + ListExecutionsResponse listExecutionsResponse = (ListExecutionsResponse) o; + return Objects.equals(this.items, listExecutionsResponse.items) + && Objects.equals(this.nextPageToken, listExecutionsResponse.nextPageToken) + && Objects.equals( + this.additionalProperties, listExecutionsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(items, nextPageToken, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListExecutionsResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" nextPageToken: ").append(toIndentedString(nextPageToken)).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("items", "nextPageToken")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("items")); + } + + /** + * 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 ListExecutionsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListExecutionsResponse.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 ListExecutionsResponse is not found in the empty JSON string", + ListExecutionsResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListExecutionsResponse.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(); + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `items` to be an array in the JSON string but got `%s`", + jsonObj.get("items").toString())); + } + + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + ListExecutionsItem.validateJsonElement(jsonArrayitems.get(i)); + } + ; + if ((jsonObj.get("nextPageToken") != null && !jsonObj.get("nextPageToken").isJsonNull()) + && !jsonObj.get("nextPageToken").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `nextPageToken` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("nextPageToken").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListExecutionsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListExecutionsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListExecutionsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListExecutionsResponse 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 ListExecutionsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListExecutionsResponse 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 ListExecutionsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListExecutionsResponse + * @throws IOException if the JSON string is invalid with respect to ListExecutionsResponse + */ + public static ListExecutionsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListExecutionsResponse.class); + } + + /** + * Convert an instance of ListExecutionsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListTemplatesResponse.java b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListTemplatesResponse.java new file mode 100644 index 00000000..bed62ddf --- /dev/null +++ b/services/automation/src/main/java/cloud/stackit/sdk/automation/v1betaapi/model/ListTemplatesResponse.java @@ -0,0 +1,358 @@ +/* + * STACKIT Automation Service API + * API endpoints for automation management . + * + * The version of the OpenAPI document: 1beta.0 + * Contact: support@stackit.de + * + * 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.automation.v1betaapi.model; + +import cloud.stackit.sdk.automation.v1betaapi.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** ListTemplatesResponse */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.19.0") +public class ListTemplatesResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List