From 77c844288899ddc6e1d0f0792b8bbe1ea0bf0c54 Mon Sep 17 00:00:00 2001 From: SDK Generator Bot Date: Fri, 30 Jan 2026 16:38:28 +0000 Subject: [PATCH] Generate sfs --- services/sfs/README.md | 85 + services/sfs/build.gradle | 19 + services/sfs/oas_commit | 1 + .../cloud/stackit/sdk/sfs/ApiCallback.java | 60 + .../java/cloud/stackit/sdk/sfs/ApiClient.java | 1548 ++++++ .../cloud/stackit/sdk/sfs/ApiResponse.java | 73 + .../sdk/sfs/GzipRequestInterceptor.java | 87 + .../main/java/cloud/stackit/sdk/sfs/JSON.java | 521 ++ .../main/java/cloud/stackit/sdk/sfs/Pair.java | 38 + .../stackit/sdk/sfs/ProgressRequestBody.java | 71 + .../stackit/sdk/sfs/ProgressResponseBody.java | 68 + .../stackit/sdk/sfs/ServerConfiguration.java | 79 + .../cloud/stackit/sdk/sfs/ServerVariable.java | 37 + .../cloud/stackit/sdk/sfs/StringUtil.java | 83 + .../cloud/stackit/sdk/sfs/api/DefaultApi.java | 4608 +++++++++++++++++ .../cloud/stackit/sdk/sfs/api/SfsApi.java | 63 + .../sdk/sfs/model/AbstractOpenApiSchema.java | 145 + .../sfs/model/CreateResourcePoolPayload.java | 556 ++ .../sfs/model/CreateResourcePoolResponse.java | 291 ++ .../CreateResourcePoolSnapshotPayload.java | 350 ++ .../CreateResourcePoolSnapshotResponse.java | 306 ++ .../model/CreateShareExportPolicyPayload.java | 394 ++ .../CreateShareExportPolicyRequestRule.java | 478 ++ .../CreateShareExportPolicyResponse.java | 303 ++ .../sdk/sfs/model/CreateSharePayload.java | 415 ++ .../sdk/sfs/model/CreateShareResponse.java | 289 ++ .../cloud/stackit/sdk/sfs/model/Error.java | 382 ++ .../sfs/model/GetResourcePoolResponse.java | 291 ++ .../GetResourcePoolSnapshotResponse.java | 304 ++ .../model/GetShareExportPolicyResponse.java | 302 ++ .../sdk/sfs/model/GetShareResponse.java | 288 ++ .../sdk/sfs/model/GoogleProtobufAny.java | 295 ++ .../model/ListPerformanceClassesResponse.java | 328 ++ .../ListResourcePoolSnapshotsResponse.java | 331 ++ .../sfs/model/ListResourcePoolsResponse.java | 315 ++ .../ListShareExportPoliciesResponse.java | 329 ++ .../sdk/sfs/model/ListSharesResponse.java | 313 ++ .../model/ListSnapshotSchedulesResponse.java | 328 ++ .../sdk/sfs/model/PerformanceClass.java | 341 ++ .../stackit/sdk/sfs/model/ResourcePool.java | 764 +++ .../model/ResourcePoolPerformanceClass.java | 349 ++ .../sdk/sfs/model/ResourcePoolSnapshot.java | 470 ++ .../sdk/sfs/model/ResourcePoolSpace.java | 358 ++ .../cloud/stackit/sdk/sfs/model/Share.java | 546 ++ .../sdk/sfs/model/ShareExportPolicy.java | 480 ++ .../sdk/sfs/model/ShareExportPolicyRule.java | 533 ++ .../sdk/sfs/model/SnapshotSchedule.java | 323 ++ .../cloud/stackit/sdk/sfs/model/Status.java | 367 ++ .../sfs/model/UpdateResourcePoolPayload.java | 504 ++ .../sfs/model/UpdateResourcePoolResponse.java | 291 ++ .../UpdateShareExportPolicyBodyRule.java | 474 ++ .../model/UpdateShareExportPolicyPayload.java | 381 ++ .../UpdateShareExportPolicyResponse.java | 303 ++ .../sdk/sfs/model/UpdateSharePayload.java | 383 ++ .../sdk/sfs/model/UpdateShareResponse.java | 289 ++ .../sdk/sfs/model/ValidationError.java | 435 ++ .../sdk/sfs/model/ValidationErrorField.java | 336 ++ .../stackit/sdk/sfs/api/DefaultApiTest.java | 66 + .../cloud/stackit/sdk/sfs/api/SfsApiTest.java | 67 + 59 files changed, 22834 insertions(+) create mode 100644 services/sfs/README.md create mode 100644 services/sfs/build.gradle create mode 100644 services/sfs/oas_commit create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiCallback.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiClient.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/GzipRequestInterceptor.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/JSON.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/Pair.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressRequestBody.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressResponseBody.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerConfiguration.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerVariable.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/StringUtil.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/DefaultApi.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/SfsApi.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/AbstractOpenApiSchema.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolPayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotPayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyPayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyRequestRule.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateSharePayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Error.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolSnapshotResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareExportPolicyResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GoogleProtobufAny.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListPerformanceClassesResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolSnapshotsResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolsResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListShareExportPoliciesResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSharesResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSnapshotSchedulesResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/PerformanceClass.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePool.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolPerformanceClass.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSnapshot.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSpace.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Share.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicy.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicyRule.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/SnapshotSchedule.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Status.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolPayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyBodyRule.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyPayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateSharePayload.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareResponse.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationError.java create mode 100644 services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationErrorField.java create mode 100644 services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/DefaultApiTest.java create mode 100644 services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/SfsApiTest.java diff --git a/services/sfs/README.md b/services/sfs/README.md new file mode 100644 index 0000000..65bfcf7 --- /dev/null +++ b/services/sfs/README.md @@ -0,0 +1,85 @@ +# STACKIT Java SDK for STACKIT File Storage (SFS) + +- API version: 1beta.0.0 + +API used to create and manage NFS Shares. + + +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/sfs). + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + sfs + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() + } + + dependencies { + implementation "cloud.stackit.sdk:sfs:" + } +``` + +## 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:sfs:publishToMavenLocal +``` + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + sfs + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenLocal() + } + + dependencies { + implementation "cloud.stackit.sdk:sfs:" + } +``` + +## Getting Started + +See the [sfs examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/sfs/src/main/java/cloud/stackit/sdk/sfs/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/sfs/build.gradle b/services/sfs/build.gradle new file mode 100644 index 0000000..10cd648 --- /dev/null +++ b/services/sfs/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.6' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.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/sfs/oas_commit b/services/sfs/oas_commit new file mode 100644 index 0000000..148a7d9 --- /dev/null +++ b/services/sfs/oas_commit @@ -0,0 +1 @@ +ed4e4fbee2f5db4d95725108fb3d736e5363fb2f diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiCallback.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiCallback.java new file mode 100644 index 0000000..5ff8911 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiCallback.java @@ -0,0 +1,60 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiClient.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiClient.java new file mode 100644 index 0000000..8a07bb1 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiClient.java @@ -0,0 +1,1548 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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://sfs.api.stackit.cloud"; + protected List servers = + new ArrayList( + Arrays.asList( + new ServerConfiguration( + "https://sfs.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 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/sfs"); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://sfs.api.stackit.cloud + * @return An instance of OkHttpClient + */ + 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; + } + + /** + * 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.sfs.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.sfs.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.sfs.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.sfs.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + * Set LenientOnJson. + * + * @param lenientOnJson a boolean + * @return a {@link cloud.stackit.sdk.sfs.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)) { + 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( + "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("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader( + "Cookie", String.format("%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(); + 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/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiResponse.java new file mode 100644 index 0000000..54ad538 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ApiResponse.java @@ -0,0 +1,73 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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/sfs/src/main/java/cloud/stackit/sdk/sfs/GzipRequestInterceptor.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/GzipRequestInterceptor.java new file mode 100644 index 0000000..5fa3f18 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/GzipRequestInterceptor.java @@ -0,0 +1,87 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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/sfs/src/main/java/cloud/stackit/sdk/sfs/JSON.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/JSON.java new file mode 100644 index 0000000..8917f2e --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/JSON.java @@ -0,0 +1,521 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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 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.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(); + 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.sfs.model.CreateResourcePoolPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateResourcePoolResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateResourcePoolSnapshotPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateResourcePoolSnapshotResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateShareExportPolicyPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateShareExportPolicyRequestRule + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateShareExportPolicyResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateSharePayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.CreateShareResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.Error.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.GetResourcePoolResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.GetResourcePoolSnapshotResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.GetShareExportPolicyResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.GetShareResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.GoogleProtobufAny.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListPerformanceClassesResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListResourcePoolSnapshotsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListResourcePoolsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListShareExportPoliciesResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListSharesResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ListSnapshotSchedulesResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.PerformanceClass.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ResourcePool.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ResourcePoolPerformanceClass + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ResourcePoolSnapshot.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ResourcePoolSpace.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.Share.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ShareExportPolicy.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ShareExportPolicyRule.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.SnapshotSchedule.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.Status.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateResourcePoolPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateResourcePoolResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateShareExportPolicyBodyRule + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateShareExportPolicyPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateShareExportPolicyResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateSharePayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.UpdateShareResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ValidationError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.sfs.model.ValidationErrorField.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/sfs/src/main/java/cloud/stackit/sdk/sfs/Pair.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/Pair.java new file mode 100644 index 0000000..0576c5d --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/Pair.java @@ -0,0 +1,38 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.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/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressRequestBody.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressRequestBody.java new file mode 100644 index 0000000..9091eb7 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressRequestBody.java @@ -0,0 +1,71 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressResponseBody.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressResponseBody.java new file mode 100644 index 0000000..9250b9b --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ProgressResponseBody.java @@ -0,0 +1,68 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +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/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerConfiguration.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerConfiguration.java new file mode 100644 index 0000000..d98f67e --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerConfiguration.java @@ -0,0 +1,79 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +import java.util.Map; + +/** Representing a Server configuration. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.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/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerVariable.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerVariable.java new file mode 100644 index 0000000..ba0dbdb --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +import java.util.HashSet; + +/** Representing a Server Variable for server URL template substitution. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.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/sfs/src/main/java/cloud/stackit/sdk/sfs/StringUtil.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/StringUtil.java new file mode 100644 index 0000000..200944d --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/StringUtil.java @@ -0,0 +1,83 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.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/sfs/src/main/java/cloud/stackit/sdk/sfs/api/DefaultApi.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/DefaultApi.java new file mode 100644 index 0000000..c1513be --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/DefaultApi.java @@ -0,0 +1,4608 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import cloud.stackit.sdk.sfs.ApiCallback; +import cloud.stackit.sdk.sfs.ApiClient; +import cloud.stackit.sdk.sfs.ApiResponse; +import cloud.stackit.sdk.sfs.Pair; +import cloud.stackit.sdk.sfs.model.CreateResourcePoolPayload; +import cloud.stackit.sdk.sfs.model.CreateResourcePoolResponse; +import cloud.stackit.sdk.sfs.model.CreateResourcePoolSnapshotPayload; +import cloud.stackit.sdk.sfs.model.CreateResourcePoolSnapshotResponse; +import cloud.stackit.sdk.sfs.model.CreateShareExportPolicyPayload; +import cloud.stackit.sdk.sfs.model.CreateShareExportPolicyResponse; +import cloud.stackit.sdk.sfs.model.CreateSharePayload; +import cloud.stackit.sdk.sfs.model.CreateShareResponse; +import cloud.stackit.sdk.sfs.model.GetResourcePoolResponse; +import cloud.stackit.sdk.sfs.model.GetResourcePoolSnapshotResponse; +import cloud.stackit.sdk.sfs.model.GetShareExportPolicyResponse; +import cloud.stackit.sdk.sfs.model.GetShareResponse; +import cloud.stackit.sdk.sfs.model.ListPerformanceClassesResponse; +import cloud.stackit.sdk.sfs.model.ListResourcePoolSnapshotsResponse; +import cloud.stackit.sdk.sfs.model.ListResourcePoolsResponse; +import cloud.stackit.sdk.sfs.model.ListShareExportPoliciesResponse; +import cloud.stackit.sdk.sfs.model.ListSharesResponse; +import cloud.stackit.sdk.sfs.model.ListSnapshotSchedulesResponse; +import cloud.stackit.sdk.sfs.model.UpdateResourcePoolPayload; +import cloud.stackit.sdk.sfs.model.UpdateResourcePoolResponse; +import cloud.stackit.sdk.sfs.model.UpdateShareExportPolicyPayload; +import cloud.stackit.sdk.sfs.model.UpdateShareExportPolicyResponse; +import cloud.stackit.sdk.sfs.model.UpdateSharePayload; +import cloud.stackit.sdk.sfs.model.UpdateShareResponse; +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 createResourcePool + * + * @param projectId (required) + * @param region (required) + * @param createResourcePoolPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createResourcePoolCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateResourcePoolPayload createResourcePoolPayload, + 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 = createResourcePoolPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/resourcePools" + .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", "application/problem+json", "text/plain" + }; + 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 createResourcePoolValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateResourcePoolPayload createResourcePoolPayload, + 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 createResourcePool(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createResourcePool(Async)"); + } + + // verify the required parameter 'createResourcePoolPayload' is set + if (createResourcePoolPayload == null) { + throw new ApiException( + "Missing the required parameter 'createResourcePoolPayload' when calling createResourcePool(Async)"); + } + + return createResourcePoolCall(projectId, region, createResourcePoolPayload, _callback); + } + + /** + * Create Resource Pool Create a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param createResourcePoolPayload (required) + * @return CreateResourcePoolResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public CreateResourcePoolResponse createResourcePool( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateResourcePoolPayload createResourcePoolPayload) + throws ApiException { + ApiResponse localVarResp = + createResourcePoolWithHttpInfo(projectId, region, createResourcePoolPayload); + return localVarResp.getData(); + } + + /** + * Create Resource Pool Create a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param createResourcePoolPayload (required) + * @return ApiResponse<CreateResourcePoolResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse createResourcePoolWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateResourcePoolPayload createResourcePoolPayload) + throws ApiException { + okhttp3.Call localVarCall = + createResourcePoolValidateBeforeCall( + projectId, region, createResourcePoolPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Resource Pool (asynchronously) Create a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param createResourcePoolPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createResourcePoolAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateResourcePoolPayload createResourcePoolPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createResourcePoolValidateBeforeCall( + projectId, region, createResourcePoolPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createResourcePoolSnapshot + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createResourcePoolSnapshotPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createResourcePoolSnapshotCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload, + 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 = createResourcePoolSnapshotPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/resourcePools/{resourcePoolId}/snapshots" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 createResourcePoolSnapshotValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload, + 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 createResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling createResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'createResourcePoolSnapshotPayload' is set + if (createResourcePoolSnapshotPayload == null) { + throw new ApiException( + "Missing the required parameter 'createResourcePoolSnapshotPayload' when calling createResourcePoolSnapshot(Async)"); + } + + return createResourcePoolSnapshotCall( + projectId, region, resourcePoolId, createResourcePoolSnapshotPayload, _callback); + } + + /** + * Create Resource Pool Snapshot Creates a Snapshot of a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createResourcePoolSnapshotPayload (required) + * @return CreateResourcePoolSnapshotResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public CreateResourcePoolSnapshotResponse createResourcePoolSnapshot( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload) + throws ApiException { + ApiResponse localVarResp = + createResourcePoolSnapshotWithHttpInfo( + projectId, region, resourcePoolId, createResourcePoolSnapshotPayload); + return localVarResp.getData(); + } + + /** + * Create Resource Pool Snapshot Creates a Snapshot of a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createResourcePoolSnapshotPayload (required) + * @return ApiResponse<CreateResourcePoolSnapshotResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse createResourcePoolSnapshotWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload) + throws ApiException { + okhttp3.Call localVarCall = + createResourcePoolSnapshotValidateBeforeCall( + projectId, region, resourcePoolId, createResourcePoolSnapshotPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Resource Pool Snapshot (asynchronously) Creates a Snapshot of a Resource Pool in a + * project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createResourcePoolSnapshotPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createResourcePoolSnapshotAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createResourcePoolSnapshotValidateBeforeCall( + projectId, + region, + resourcePoolId, + createResourcePoolSnapshotPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createShare + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createSharePayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createShareCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull CreateSharePayload createSharePayload, + 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 = createSharePayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/resourcePools/{resourcePoolId}/shares" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 createShareValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull CreateSharePayload createSharePayload, + 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 createShare(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createShare(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling createShare(Async)"); + } + + // verify the required parameter 'createSharePayload' is set + if (createSharePayload == null) { + throw new ApiException( + "Missing the required parameter 'createSharePayload' when calling createShare(Async)"); + } + + return createShareCall(projectId, region, resourcePoolId, createSharePayload, _callback); + } + + /** + * Create Share Creates a Share in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createSharePayload (required) + * @return CreateShareResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public CreateShareResponse createShare( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull CreateSharePayload createSharePayload) + throws ApiException { + ApiResponse localVarResp = + createShareWithHttpInfo(projectId, region, resourcePoolId, createSharePayload); + return localVarResp.getData(); + } + + /** + * Create Share Creates a Share in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createSharePayload (required) + * @return ApiResponse<CreateShareResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse createShareWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull CreateSharePayload createSharePayload) + throws ApiException { + okhttp3.Call localVarCall = + createShareValidateBeforeCall( + projectId, region, resourcePoolId, createSharePayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Share (asynchronously) Creates a Share in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param createSharePayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createShareAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull CreateSharePayload createSharePayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createShareValidateBeforeCall( + projectId, region, resourcePoolId, createSharePayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createShareExportPolicy + * + * @param projectId (required) + * @param region (required) + * @param createShareExportPolicyPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createShareExportPolicyCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateShareExportPolicyPayload createShareExportPolicyPayload, + 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 = createShareExportPolicyPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/shareExportPolicies" + .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", "application/problem+json", "text/plain" + }; + 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 createShareExportPolicyValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateShareExportPolicyPayload createShareExportPolicyPayload, + 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 createShareExportPolicy(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createShareExportPolicy(Async)"); + } + + // verify the required parameter 'createShareExportPolicyPayload' is set + if (createShareExportPolicyPayload == null) { + throw new ApiException( + "Missing the required parameter 'createShareExportPolicyPayload' when calling createShareExportPolicy(Async)"); + } + + return createShareExportPolicyCall( + projectId, region, createShareExportPolicyPayload, _callback); + } + + /** + * Create Share Export Policy Creates a ShareExportPolicy in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param createShareExportPolicyPayload (required) + * @return CreateShareExportPolicyResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public CreateShareExportPolicyResponse createShareExportPolicy( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateShareExportPolicyPayload createShareExportPolicyPayload) + throws ApiException { + ApiResponse localVarResp = + createShareExportPolicyWithHttpInfo( + projectId, region, createShareExportPolicyPayload); + return localVarResp.getData(); + } + + /** + * Create Share Export Policy Creates a ShareExportPolicy in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param createShareExportPolicyPayload (required) + * @return ApiResponse<CreateShareExportPolicyResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse createShareExportPolicyWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateShareExportPolicyPayload createShareExportPolicyPayload) + throws ApiException { + okhttp3.Call localVarCall = + createShareExportPolicyValidateBeforeCall( + projectId, region, createShareExportPolicyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Share Export Policy (asynchronously) Creates a ShareExportPolicy in a Resource Pool in + * a project. + * + * @param projectId (required) + * @param region (required) + * @param createShareExportPolicyPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call createShareExportPolicyAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateShareExportPolicyPayload createShareExportPolicyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createShareExportPolicyValidateBeforeCall( + projectId, region, createShareExportPolicyPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteResourcePool + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteResourcePoolCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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}/resourcePools/{resourcePoolId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 deleteResourcePoolValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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 deleteResourcePool(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteResourcePool(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling deleteResourcePool(Async)"); + } + + return deleteResourcePoolCall(projectId, region, resourcePoolId, _callback); + } + + /** + * Delete Resource Pool Deletes a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return Object + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public Object deleteResourcePool( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + ApiResponse localVarResp = + deleteResourcePoolWithHttpInfo(projectId, region, resourcePoolId); + return localVarResp.getData(); + } + + /** + * Delete Resource Pool Deletes a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ApiResponse<Object> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse deleteResourcePoolWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + okhttp3.Call localVarCall = + deleteResourcePoolValidateBeforeCall(projectId, region, resourcePoolId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete Resource Pool (asynchronously) Deletes a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteResourcePoolAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteResourcePoolValidateBeforeCall(projectId, region, resourcePoolId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteResourcePoolSnapshot + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteResourcePoolSnapshotCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + 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}/resourcePools/{resourcePoolId}/snapshots/{snapshotName}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.toString())) + .replace( + "{" + "snapshotName" + "}", + localVarApiClient.escapeString(snapshotName.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", "application/problem+json", "text/plain" + }; + 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 deleteResourcePoolSnapshotValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + 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 deleteResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling deleteResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'snapshotName' is set + if (snapshotName == null) { + throw new ApiException( + "Missing the required parameter 'snapshotName' when calling deleteResourcePoolSnapshot(Async)"); + } + + return deleteResourcePoolSnapshotCall( + projectId, region, resourcePoolId, snapshotName, _callback); + } + + /** + * Delete Resource Pool Snapshot Deletes a Snapshot from a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (required) + * @return Object + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public Object deleteResourcePoolSnapshot( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName) + throws ApiException { + ApiResponse localVarResp = + deleteResourcePoolSnapshotWithHttpInfo( + projectId, region, resourcePoolId, snapshotName); + return localVarResp.getData(); + } + + /** + * Delete Resource Pool Snapshot Deletes a Snapshot from a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (required) + * @return ApiResponse<Object> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse deleteResourcePoolSnapshotWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName) + throws ApiException { + okhttp3.Call localVarCall = + deleteResourcePoolSnapshotValidateBeforeCall( + projectId, region, resourcePoolId, snapshotName, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete Resource Pool Snapshot (asynchronously) Deletes a Snapshot from a Resource Pool in a + * project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteResourcePoolSnapshotAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteResourcePoolSnapshotValidateBeforeCall( + projectId, region, resourcePoolId, snapshotName, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteShare + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteShareCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + 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}/resourcePools/{resourcePoolId}/shares/{shareId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.toString())) + .replace( + "{" + "shareId" + "}", + localVarApiClient.escapeString(shareId.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", "application/problem+json", "text/plain" + }; + 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 deleteShareValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + 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 deleteShare(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteShare(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling deleteShare(Async)"); + } + + // verify the required parameter 'shareId' is set + if (shareId == null) { + throw new ApiException( + "Missing the required parameter 'shareId' when calling deleteShare(Async)"); + } + + return deleteShareCall(projectId, region, resourcePoolId, shareId, _callback); + } + + /** + * Delete Share Deletes a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @return Object + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public Object deleteShare( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId) + throws ApiException { + ApiResponse localVarResp = + deleteShareWithHttpInfo(projectId, region, resourcePoolId, shareId); + return localVarResp.getData(); + } + + /** + * Delete Share Deletes a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @return ApiResponse<Object> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse deleteShareWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId) + throws ApiException { + okhttp3.Call localVarCall = + deleteShareValidateBeforeCall(projectId, region, resourcePoolId, shareId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete Share (asynchronously) Deletes a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteShareAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteShareValidateBeforeCall( + projectId, region, resourcePoolId, shareId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteShareExportPolicy + * + * @param projectId (required) + * @param region (required) + * @param policyId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteShareExportPolicyCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + 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}/shareExportPolicies/{policyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "policyId" + "}", + localVarApiClient.escapeString(policyId.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", "application/problem+json", "text/plain" + }; + 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 deleteShareExportPolicyValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + 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 deleteShareExportPolicy(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteShareExportPolicy(Async)"); + } + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + "Missing the required parameter 'policyId' when calling deleteShareExportPolicy(Async)"); + } + + return deleteShareExportPolicyCall(projectId, region, policyId, _callback); + } + + /** + * Delete Share Export Policy Deletes a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @return Object + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public Object deleteShareExportPolicy( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId) + throws ApiException { + ApiResponse localVarResp = + deleteShareExportPolicyWithHttpInfo(projectId, region, policyId); + return localVarResp.getData(); + } + + /** + * Delete Share Export Policy Deletes a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @return ApiResponse<Object> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse deleteShareExportPolicyWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId) + throws ApiException { + okhttp3.Call localVarCall = + deleteShareExportPolicyValidateBeforeCall(projectId, region, policyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete Share Export Policy (asynchronously) Deletes a ShareExportPolicies in a Resource Pool + * in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call deleteShareExportPolicyAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteShareExportPolicyValidateBeforeCall(projectId, region, policyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getResourcePool + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getResourcePoolCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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}/resourcePools/{resourcePoolId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 getResourcePoolValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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 getResourcePool(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getResourcePool(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling getResourcePool(Async)"); + } + + return getResourcePoolCall(projectId, region, resourcePoolId, _callback); + } + + /** + * Get Resource Pool Retrieves a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return GetResourcePoolResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public GetResourcePoolResponse getResourcePool( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + ApiResponse localVarResp = + getResourcePoolWithHttpInfo(projectId, region, resourcePoolId); + return localVarResp.getData(); + } + + /** + * Get Resource Pool Retrieves a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ApiResponse<GetResourcePoolResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse getResourcePoolWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + okhttp3.Call localVarCall = + getResourcePoolValidateBeforeCall(projectId, region, resourcePoolId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Resource Pool (asynchronously) Retrieves a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getResourcePoolAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getResourcePoolValidateBeforeCall(projectId, region, resourcePoolId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getResourcePoolSnapshot + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getResourcePoolSnapshotCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + 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}/resourcePools/{resourcePoolId}/snapshots/{snapshotName}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.toString())) + .replace( + "{" + "snapshotName" + "}", + localVarApiClient.escapeString(snapshotName.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", "application/problem+json", "text/plain" + }; + 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 getResourcePoolSnapshotValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + 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 getResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling getResourcePoolSnapshot(Async)"); + } + + // verify the required parameter 'snapshotName' is set + if (snapshotName == null) { + throw new ApiException( + "Missing the required parameter 'snapshotName' when calling getResourcePoolSnapshot(Async)"); + } + + return getResourcePoolSnapshotCall( + projectId, region, resourcePoolId, snapshotName, _callback); + } + + /** + * Get Resource Pool Snapshot Retrieves a Snapshot from a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (required) + * @return GetResourcePoolSnapshotResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public GetResourcePoolSnapshotResponse getResourcePoolSnapshot( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName) + throws ApiException { + ApiResponse localVarResp = + getResourcePoolSnapshotWithHttpInfo( + projectId, region, resourcePoolId, snapshotName); + return localVarResp.getData(); + } + + /** + * Get Resource Pool Snapshot Retrieves a Snapshot from a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (required) + * @return ApiResponse<GetResourcePoolSnapshotResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse getResourcePoolSnapshotWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName) + throws ApiException { + okhttp3.Call localVarCall = + getResourcePoolSnapshotValidateBeforeCall( + projectId, region, resourcePoolId, snapshotName, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Resource Pool Snapshot (asynchronously) Retrieves a Snapshot from a Resource Pool in a + * project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param snapshotName (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getResourcePoolSnapshotAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String snapshotName, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getResourcePoolSnapshotValidateBeforeCall( + projectId, region, resourcePoolId, snapshotName, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getShare + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getShareCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + 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}/resourcePools/{resourcePoolId}/shares/{shareId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.toString())) + .replace( + "{" + "shareId" + "}", + localVarApiClient.escapeString(shareId.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", "application/problem+json", "text/plain" + }; + 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 getShareValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + 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 getShare(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getShare(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling getShare(Async)"); + } + + // verify the required parameter 'shareId' is set + if (shareId == null) { + throw new ApiException( + "Missing the required parameter 'shareId' when calling getShare(Async)"); + } + + return getShareCall(projectId, region, resourcePoolId, shareId, _callback); + } + + /** + * Get Share Retrieves a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @return GetShareResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public GetShareResponse getShare( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId) + throws ApiException { + ApiResponse localVarResp = + getShareWithHttpInfo(projectId, region, resourcePoolId, shareId); + return localVarResp.getData(); + } + + /** + * Get Share Retrieves a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @return ApiResponse<GetShareResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse getShareWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId) + throws ApiException { + okhttp3.Call localVarCall = + getShareValidateBeforeCall(projectId, region, resourcePoolId, shareId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Share (asynchronously) Retrieves a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getShareAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getShareValidateBeforeCall(projectId, region, resourcePoolId, shareId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getShareExportPolicy + * + * @param projectId (required) + * @param region (required) + * @param policyId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getShareExportPolicyCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + 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}/shareExportPolicies/{policyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "policyId" + "}", + localVarApiClient.escapeString(policyId.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", "application/problem+json", "text/plain" + }; + 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 getShareExportPolicyValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + 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 getShareExportPolicy(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getShareExportPolicy(Async)"); + } + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + "Missing the required parameter 'policyId' when calling getShareExportPolicy(Async)"); + } + + return getShareExportPolicyCall(projectId, region, policyId, _callback); + } + + /** + * Get Share Export Policy Retrieves a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @return GetShareExportPolicyResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public GetShareExportPolicyResponse getShareExportPolicy( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId) + throws ApiException { + ApiResponse localVarResp = + getShareExportPolicyWithHttpInfo(projectId, region, policyId); + return localVarResp.getData(); + } + + /** + * Get Share Export Policy Retrieves a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @return ApiResponse<GetShareExportPolicyResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse getShareExportPolicyWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId) + throws ApiException { + okhttp3.Call localVarCall = + getShareExportPolicyValidateBeforeCall(projectId, region, policyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Share Export Policy (asynchronously) Retrieves a ShareExportPolicies in a Resource Pool + * in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call getShareExportPolicyAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getShareExportPolicyValidateBeforeCall(projectId, region, policyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listPerformanceClasses + * + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listPerformanceClassesCall(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/resourcePoolPerformanceClasses"; + + 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", "application/problem+json", "text/plain" + }; + 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 listPerformanceClassesValidateBeforeCall(final ApiCallback _callback) + throws ApiException { + return listPerformanceClassesCall(_callback); + } + + /** + * List Resource Performance Classes Lists all performances classes available + * + * @return ListPerformanceClassesResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListPerformanceClassesResponse listPerformanceClasses() throws ApiException { + ApiResponse localVarResp = + listPerformanceClassesWithHttpInfo(); + return localVarResp.getData(); + } + + /** + * List Resource Performance Classes Lists all performances classes available + * + * @return ApiResponse<ListPerformanceClassesResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listPerformanceClassesWithHttpInfo() + throws ApiException { + okhttp3.Call localVarCall = listPerformanceClassesValidateBeforeCall(null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Resource Performance Classes (asynchronously) Lists all performances classes available + * + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listPerformanceClassesAsync( + final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listPerformanceClassesValidateBeforeCall(_callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listResourcePoolSnapshots + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listResourcePoolSnapshotsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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}/resourcePools/{resourcePoolId}/snapshots" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 listResourcePoolSnapshotsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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 listResourcePoolSnapshots(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listResourcePoolSnapshots(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling listResourcePoolSnapshots(Async)"); + } + + return listResourcePoolSnapshotsCall(projectId, region, resourcePoolId, _callback); + } + + /** + * List Resource Pool Snapshots Lists the Snapshots of a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ListResourcePoolSnapshotsResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListResourcePoolSnapshotsResponse listResourcePoolSnapshots( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + ApiResponse localVarResp = + listResourcePoolSnapshotsWithHttpInfo(projectId, region, resourcePoolId); + return localVarResp.getData(); + } + + /** + * List Resource Pool Snapshots Lists the Snapshots of a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ApiResponse<ListResourcePoolSnapshotsResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listResourcePoolSnapshotsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + okhttp3.Call localVarCall = + listResourcePoolSnapshotsValidateBeforeCall( + projectId, region, resourcePoolId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Resource Pool Snapshots (asynchronously) Lists the Snapshots of a Resource Pool in a + * project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listResourcePoolSnapshotsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listResourcePoolSnapshotsValidateBeforeCall( + projectId, region, resourcePoolId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listResourcePools + * + * @param projectId (required) + * @param region (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listResourcePoolsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + 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}/resourcePools" + .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", "application/problem+json", "text/plain" + }; + 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 listResourcePoolsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + 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 listResourcePools(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listResourcePools(Async)"); + } + + return listResourcePoolsCall(projectId, region, _callback); + } + + /** + * List Resource Pools Lists Resource Pools in a project. + * + * @param projectId (required) + * @param region (required) + * @return ListResourcePoolsResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListResourcePoolsResponse listResourcePools( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + ApiResponse localVarResp = + listResourcePoolsWithHttpInfo(projectId, region); + return localVarResp.getData(); + } + + /** + * List Resource Pools Lists Resource Pools in a project. + * + * @param projectId (required) + * @param region (required) + * @return ApiResponse<ListResourcePoolsResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listResourcePoolsWithHttpInfo( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + okhttp3.Call localVarCall = listResourcePoolsValidateBeforeCall(projectId, region, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Resource Pools (asynchronously) Lists Resource Pools in a project. + * + * @param projectId (required) + * @param region (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listResourcePoolsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listResourcePoolsValidateBeforeCall(projectId, region, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listShareExportPolicies + * + * @param projectId (required) + * @param region (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listShareExportPoliciesCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + 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}/shareExportPolicies" + .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", "application/problem+json", "text/plain" + }; + 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 listShareExportPoliciesValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + 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 listShareExportPolicies(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listShareExportPolicies(Async)"); + } + + return listShareExportPoliciesCall(projectId, region, _callback); + } + + /** + * List Share Export Policies Lists ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @return ListShareExportPoliciesResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListShareExportPoliciesResponse listShareExportPolicies( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + ApiResponse localVarResp = + listShareExportPoliciesWithHttpInfo(projectId, region); + return localVarResp.getData(); + } + + /** + * List Share Export Policies Lists ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @return ApiResponse<ListShareExportPoliciesResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listShareExportPoliciesWithHttpInfo( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + okhttp3.Call localVarCall = + listShareExportPoliciesValidateBeforeCall(projectId, region, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Share Export Policies (asynchronously) Lists ShareExportPolicies in a Resource Pool in a + * project. + * + * @param projectId (required) + * @param region (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listShareExportPoliciesAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listShareExportPoliciesValidateBeforeCall(projectId, region, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listShares + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listSharesCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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}/resourcePools/{resourcePoolId}/shares" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 listSharesValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + 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 listShares(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listShares(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling listShares(Async)"); + } + + return listSharesCall(projectId, region, resourcePoolId, _callback); + } + + /** + * List Shares Lists Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ListSharesResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListSharesResponse listShares( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + ApiResponse localVarResp = + listSharesWithHttpInfo(projectId, region, resourcePoolId); + return localVarResp.getData(); + } + + /** + * List Shares Lists Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @return ApiResponse<ListSharesResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listSharesWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId) + throws ApiException { + okhttp3.Call localVarCall = + listSharesValidateBeforeCall(projectId, region, resourcePoolId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Shares (asynchronously) Lists Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listSharesAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listSharesValidateBeforeCall(projectId, region, resourcePoolId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listSnapshotSchedules + * + * @param projectId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listSnapshotSchedulesCall( + @javax.annotation.Nonnull String projectId, 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}/snapshotSchedules" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.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", "application/problem+json", "text/plain" + }; + 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 listSnapshotSchedulesValidateBeforeCall( + @javax.annotation.Nonnull String projectId, 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 listSnapshotSchedules(Async)"); + } + + return listSnapshotSchedulesCall(projectId, _callback); + } + + /** + * List Snapshot Schedules Lists snapshot schedules + * + * @param projectId (required) + * @return ListSnapshotSchedulesResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ListSnapshotSchedulesResponse listSnapshotSchedules( + @javax.annotation.Nonnull String projectId) throws ApiException { + ApiResponse localVarResp = + listSnapshotSchedulesWithHttpInfo(projectId); + return localVarResp.getData(); + } + + /** + * List Snapshot Schedules Lists snapshot schedules + * + * @param projectId (required) + * @return ApiResponse<ListSnapshotSchedulesResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse listSnapshotSchedulesWithHttpInfo( + @javax.annotation.Nonnull String projectId) throws ApiException { + okhttp3.Call localVarCall = listSnapshotSchedulesValidateBeforeCall(projectId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Snapshot Schedules (asynchronously) Lists snapshot schedules + * + * @param projectId (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call listSnapshotSchedulesAsync( + @javax.annotation.Nonnull String projectId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = listSnapshotSchedulesValidateBeforeCall(projectId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateResourcePool + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param updateResourcePoolPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateResourcePoolCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull UpdateResourcePoolPayload updateResourcePoolPayload, + 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 = updateResourcePoolPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/resourcePools/{resourcePoolId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.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", "application/problem+json", "text/plain" + }; + 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 updateResourcePoolValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull UpdateResourcePoolPayload updateResourcePoolPayload, + 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 updateResourcePool(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateResourcePool(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling updateResourcePool(Async)"); + } + + // verify the required parameter 'updateResourcePoolPayload' is set + if (updateResourcePoolPayload == null) { + throw new ApiException( + "Missing the required parameter 'updateResourcePoolPayload' when calling updateResourcePool(Async)"); + } + + return updateResourcePoolCall( + projectId, region, resourcePoolId, updateResourcePoolPayload, _callback); + } + + /** + * Update Resource Pool Updates a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param updateResourcePoolPayload (required) + * @return UpdateResourcePoolResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public UpdateResourcePoolResponse updateResourcePool( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull UpdateResourcePoolPayload updateResourcePoolPayload) + throws ApiException { + ApiResponse localVarResp = + updateResourcePoolWithHttpInfo( + projectId, region, resourcePoolId, updateResourcePoolPayload); + return localVarResp.getData(); + } + + /** + * Update Resource Pool Updates a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param updateResourcePoolPayload (required) + * @return ApiResponse<UpdateResourcePoolResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse updateResourcePoolWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull UpdateResourcePoolPayload updateResourcePoolPayload) + throws ApiException { + okhttp3.Call localVarCall = + updateResourcePoolValidateBeforeCall( + projectId, region, resourcePoolId, updateResourcePoolPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Resource Pool (asynchronously) Updates a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param updateResourcePoolPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateResourcePoolAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull UpdateResourcePoolPayload updateResourcePoolPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateResourcePoolValidateBeforeCall( + projectId, region, resourcePoolId, updateResourcePoolPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateShare + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @param updateSharePayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateShareCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + @javax.annotation.Nonnull UpdateSharePayload updateSharePayload, + 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 = updateSharePayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/resourcePools/{resourcePoolId}/shares/{shareId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "resourcePoolId" + "}", + localVarApiClient.escapeString(resourcePoolId.toString())) + .replace( + "{" + "shareId" + "}", + localVarApiClient.escapeString(shareId.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", "application/problem+json", "text/plain" + }; + 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 updateShareValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + @javax.annotation.Nonnull UpdateSharePayload updateSharePayload, + 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 updateShare(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateShare(Async)"); + } + + // verify the required parameter 'resourcePoolId' is set + if (resourcePoolId == null) { + throw new ApiException( + "Missing the required parameter 'resourcePoolId' when calling updateShare(Async)"); + } + + // verify the required parameter 'shareId' is set + if (shareId == null) { + throw new ApiException( + "Missing the required parameter 'shareId' when calling updateShare(Async)"); + } + + // verify the required parameter 'updateSharePayload' is set + if (updateSharePayload == null) { + throw new ApiException( + "Missing the required parameter 'updateSharePayload' when calling updateShare(Async)"); + } + + return updateShareCall( + projectId, region, resourcePoolId, shareId, updateSharePayload, _callback); + } + + /** + * Update Share Updates a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @param updateSharePayload (required) + * @return UpdateShareResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public UpdateShareResponse updateShare( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + @javax.annotation.Nonnull UpdateSharePayload updateSharePayload) + throws ApiException { + ApiResponse localVarResp = + updateShareWithHttpInfo( + projectId, region, resourcePoolId, shareId, updateSharePayload); + return localVarResp.getData(); + } + + /** + * Update Share Updates a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @param updateSharePayload (required) + * @return ApiResponse<UpdateShareResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse updateShareWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + @javax.annotation.Nonnull UpdateSharePayload updateSharePayload) + throws ApiException { + okhttp3.Call localVarCall = + updateShareValidateBeforeCall( + projectId, region, resourcePoolId, shareId, updateSharePayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Share (asynchronously) Updates a Shares in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param resourcePoolId (required) + * @param shareId (required) + * @param updateSharePayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateShareAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String resourcePoolId, + @javax.annotation.Nonnull String shareId, + @javax.annotation.Nonnull UpdateSharePayload updateSharePayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateShareValidateBeforeCall( + projectId, region, resourcePoolId, shareId, updateSharePayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateShareExportPolicy + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @param updateShareExportPolicyPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateShareExportPolicyCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + @javax.annotation.Nonnull UpdateShareExportPolicyPayload updateShareExportPolicyPayload, + 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 = updateShareExportPolicyPayload; + + // create path and map variables + String localVarPath = + "/v1beta/projects/{projectId}/regions/{region}/shareExportPolicies/{policyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "policyId" + "}", + localVarApiClient.escapeString(policyId.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", "application/problem+json", "text/plain" + }; + 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 updateShareExportPolicyValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + @javax.annotation.Nonnull UpdateShareExportPolicyPayload updateShareExportPolicyPayload, + 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 updateShareExportPolicy(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateShareExportPolicy(Async)"); + } + + // verify the required parameter 'policyId' is set + if (policyId == null) { + throw new ApiException( + "Missing the required parameter 'policyId' when calling updateShareExportPolicy(Async)"); + } + + // verify the required parameter 'updateShareExportPolicyPayload' is set + if (updateShareExportPolicyPayload == null) { + throw new ApiException( + "Missing the required parameter 'updateShareExportPolicyPayload' when calling updateShareExportPolicy(Async)"); + } + + return updateShareExportPolicyCall( + projectId, region, policyId, updateShareExportPolicyPayload, _callback); + } + + /** + * Update Share Export Policy Updates a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @param updateShareExportPolicyPayload (required) + * @return UpdateShareExportPolicyResponse + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public UpdateShareExportPolicyResponse updateShareExportPolicy( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + @javax.annotation.Nonnull UpdateShareExportPolicyPayload updateShareExportPolicyPayload) + throws ApiException { + ApiResponse localVarResp = + updateShareExportPolicyWithHttpInfo( + projectId, region, policyId, updateShareExportPolicyPayload); + return localVarResp.getData(); + } + + /** + * Update Share Export Policy Updates a ShareExportPolicies in a Resource Pool in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @param updateShareExportPolicyPayload (required) + * @return ApiResponse<UpdateShareExportPolicyResponse> + * @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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public ApiResponse updateShareExportPolicyWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + @javax.annotation.Nonnull UpdateShareExportPolicyPayload updateShareExportPolicyPayload) + throws ApiException { + okhttp3.Call localVarCall = + updateShareExportPolicyValidateBeforeCall( + projectId, region, policyId, updateShareExportPolicyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Share Export Policy (asynchronously) Updates a ShareExportPolicies in a Resource Pool + * in a project. + * + * @param projectId (required) + * @param region (required) + * @param policyId (required) + * @param updateShareExportPolicyPayload (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 OK -
400 Some fields of the request have failed the validation procedure. -
401 Please make sure the Authorization Header is set and uses correct credentials -
500 Please retry again later or contact support if the issue persists -
+ */ + public okhttp3.Call updateShareExportPolicyAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String policyId, + @javax.annotation.Nonnull UpdateShareExportPolicyPayload updateShareExportPolicyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateShareExportPolicyValidateBeforeCall( + projectId, region, policyId, updateShareExportPolicyPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/SfsApi.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/SfsApi.java new file mode 100644 index 0000000..1ff5e4f --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/api/SfsApi.java @@ -0,0 +1,63 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import java.io.IOException; +import okhttp3.OkHttpClient; + +public class SfsApi extends DefaultApi { + /** + * Basic constructor for SfsApi + * + *

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

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public SfsApi(CoreConfiguration configuration) throws IOException { + super(configuration); + } + + /** + * Constructor for SfsApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public SfsApi(OkHttpClient httpClient) throws IOException { + super(httpClient); + } + + /** + * Constructor for SfsApi + * + * @param httpClient OkHttpClient object + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public SfsApi(OkHttpClient httpClient, CoreConfiguration configuration) throws IOException { + super(httpClient, configuration); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/AbstractOpenApiSchema.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..6b8ffe2 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/AbstractOpenApiSchema.java @@ -0,0 +1,145 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.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/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolPayload.java new file mode 100644 index 0000000..d02ed29 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolPayload.java @@ -0,0 +1,556 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateResourcePoolPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateResourcePoolPayload { + public static final String SERIALIZED_NAME_AVAILABILITY_ZONE = "availabilityZone"; + + @SerializedName(SERIALIZED_NAME_AVAILABILITY_ZONE) + @javax.annotation.Nullable private String availabilityZone; + + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PERFORMANCE_CLASS = "performanceClass"; + + @SerializedName(SERIALIZED_NAME_PERFORMANCE_CLASS) + @javax.annotation.Nullable private String performanceClass; + + public static final String SERIALIZED_NAME_SIZE_GIGABYTES = "sizeGigabytes"; + + @SerializedName(SERIALIZED_NAME_SIZE_GIGABYTES) + @javax.annotation.Nullable private Integer sizeGigabytes; + + public static final String SERIALIZED_NAME_SNAPSHOT_SCHEDULE_NAME = "snapshotScheduleName"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_SCHEDULE_NAME) + @javax.annotation.Nullable private String snapshotScheduleName; + + public static final String SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE = "snapshotsAreVisible"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE) + @javax.annotation.Nullable private Boolean snapshotsAreVisible; + + public CreateResourcePoolPayload() {} + + public CreateResourcePoolPayload availabilityZone( + @javax.annotation.Nullable String availabilityZone) { + this.availabilityZone = availabilityZone; + return this; + } + + /** + * Availability zone + * + * @return availabilityZone + */ + @javax.annotation.Nullable public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(@javax.annotation.Nullable String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public CreateResourcePoolPayload ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public CreateResourcePoolPayload addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * List of IPs that can mount the Resource Pool in read-only; IPs must have a subnet mask (e.g. + * \"172.16.0.0/24\" for a range of IPs, or \"172.16.0.250/32\" for a + * specific IP) + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public CreateResourcePoolPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateResourcePoolPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the resource pool keys are + * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot + * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public CreateResourcePoolPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Resource Pool + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public CreateResourcePoolPayload performanceClass( + @javax.annotation.Nullable String performanceClass) { + this.performanceClass = performanceClass; + return this; + } + + /** + * Name of the performance class + * + * @return performanceClass + */ + @javax.annotation.Nullable public String getPerformanceClass() { + return performanceClass; + } + + public void setPerformanceClass(@javax.annotation.Nullable String performanceClass) { + this.performanceClass = performanceClass; + } + + public CreateResourcePoolPayload sizeGigabytes( + @javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + return this; + } + + /** + * Size of the Resource Pool (unit: gibibytes) + * + * @return sizeGigabytes + */ + @javax.annotation.Nullable public Integer getSizeGigabytes() { + return sizeGigabytes; + } + + public void setSizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + } + + public CreateResourcePoolPayload snapshotScheduleName( + @javax.annotation.Nullable String snapshotScheduleName) { + this.snapshotScheduleName = snapshotScheduleName; + return this; + } + + /** + * (optional) Name of the Snapshot Schedule to use + * + * @return snapshotScheduleName + */ + @javax.annotation.Nullable public String getSnapshotScheduleName() { + return snapshotScheduleName; + } + + public void setSnapshotScheduleName(@javax.annotation.Nullable String snapshotScheduleName) { + this.snapshotScheduleName = snapshotScheduleName; + } + + public CreateResourcePoolPayload snapshotsAreVisible( + @javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + return this; + } + + /** + * Whether the .snapshot directory is visible when mounting the resource pool. Setting this + * value to false might prevent you from accessing the snapshots (e.g. for security reasons). + * Additionally, the access to the snapshots is always controlled by the export policy of the + * resource pool. That means, if snapshots are visible and the export policy allows for reading + * the resource pool, then it also allows reading the snapshot of all shares. + * + * @return snapshotsAreVisible + */ + @javax.annotation.Nullable public Boolean getSnapshotsAreVisible() { + return snapshotsAreVisible; + } + + public void setSnapshotsAreVisible(@javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + } + + /** + * 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 CreateResourcePoolPayload instance itself + */ + public CreateResourcePoolPayload 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; + } + CreateResourcePoolPayload createResourcePoolPayload = (CreateResourcePoolPayload) o; + return Objects.equals(this.availabilityZone, createResourcePoolPayload.availabilityZone) + && Objects.equals(this.ipAcl, createResourcePoolPayload.ipAcl) + && Objects.equals(this.labels, createResourcePoolPayload.labels) + && Objects.equals(this.name, createResourcePoolPayload.name) + && Objects.equals(this.performanceClass, createResourcePoolPayload.performanceClass) + && Objects.equals(this.sizeGigabytes, createResourcePoolPayload.sizeGigabytes) + && Objects.equals( + this.snapshotScheduleName, createResourcePoolPayload.snapshotScheduleName) + && Objects.equals( + this.snapshotsAreVisible, createResourcePoolPayload.snapshotsAreVisible) + && Objects.equals( + this.additionalProperties, createResourcePoolPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + availabilityZone, + ipAcl, + labels, + name, + performanceClass, + sizeGigabytes, + snapshotScheduleName, + snapshotsAreVisible, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateResourcePoolPayload {\n"); + sb.append(" availabilityZone: ").append(toIndentedString(availabilityZone)).append("\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" performanceClass: ").append(toIndentedString(performanceClass)).append("\n"); + sb.append(" sizeGigabytes: ").append(toIndentedString(sizeGigabytes)).append("\n"); + sb.append(" snapshotScheduleName: ") + .append(toIndentedString(snapshotScheduleName)) + .append("\n"); + sb.append(" snapshotsAreVisible: ") + .append(toIndentedString(snapshotsAreVisible)) + .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( + "availabilityZone", + "ipAcl", + "labels", + "name", + "performanceClass", + "sizeGigabytes", + "snapshotScheduleName", + "snapshotsAreVisible")); + + // 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 CreateResourcePoolPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateResourcePoolPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateResourcePoolPayload is not found in the empty JSON string", + CreateResourcePoolPayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("availabilityZone") != null + && !jsonObj.get("availabilityZone").isJsonNull()) + && !jsonObj.get("availabilityZone").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `availabilityZone` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("availabilityZone").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("performanceClass") != null + && !jsonObj.get("performanceClass").isJsonNull()) + && !jsonObj.get("performanceClass").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `performanceClass` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("performanceClass").toString())); + } + if ((jsonObj.get("snapshotScheduleName") != null + && !jsonObj.get("snapshotScheduleName").isJsonNull()) + && !jsonObj.get("snapshotScheduleName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `snapshotScheduleName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("snapshotScheduleName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateResourcePoolPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateResourcePoolPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateResourcePoolPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateResourcePoolPayload 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 CreateResourcePoolPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateResourcePoolPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateResourcePoolPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateResourcePoolPayload + * @throws IOException if the JSON string is invalid with respect to CreateResourcePoolPayload + */ + public static CreateResourcePoolPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateResourcePoolPayload.class); + } + + /** + * Convert an instance of CreateResourcePoolPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolResponse.java new file mode 100644 index 0000000..92d3ff0 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolResponse.java @@ -0,0 +1,291 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateResourcePoolResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateResourcePoolResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL = "resourcePool"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL) + @javax.annotation.Nullable private ResourcePool resourcePool; + + public CreateResourcePoolResponse() {} + + public CreateResourcePoolResponse resourcePool( + @javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + return this; + } + + /** + * Created Resource Pool + * + * @return resourcePool + */ + @javax.annotation.Nullable public ResourcePool getResourcePool() { + return resourcePool; + } + + public void setResourcePool(@javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + } + + /** + * 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 CreateResourcePoolResponse instance itself + */ + public CreateResourcePoolResponse 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; + } + CreateResourcePoolResponse createResourcePoolResponse = (CreateResourcePoolResponse) o; + return Objects.equals(this.resourcePool, createResourcePoolResponse.resourcePool) + && Objects.equals( + this.additionalProperties, createResourcePoolResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePool, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateResourcePoolResponse {\n"); + sb.append(" resourcePool: ").append(toIndentedString(resourcePool)).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("resourcePool")); + + // 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 CreateResourcePoolResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateResourcePoolResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateResourcePoolResponse is not found in the empty JSON string", + CreateResourcePoolResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `resourcePool` + if (jsonObj.get("resourcePool") != null && !jsonObj.get("resourcePool").isJsonNull()) { + ResourcePool.validateJsonElement(jsonObj.get("resourcePool")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateResourcePoolResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateResourcePoolResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateResourcePoolResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateResourcePoolResponse 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 CreateResourcePoolResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateResourcePoolResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateResourcePoolResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateResourcePoolResponse + * @throws IOException if the JSON string is invalid with respect to CreateResourcePoolResponse + */ + public static CreateResourcePoolResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateResourcePoolResponse.class); + } + + /** + * Convert an instance of CreateResourcePoolResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotPayload.java new file mode 100644 index 0000000..34cad6c --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotPayload.java @@ -0,0 +1,350 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** CreateResourcePoolSnapshotPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateResourcePoolSnapshotPayload { + public static final String SERIALIZED_NAME_COMMENT = "comment"; + + @SerializedName(SERIALIZED_NAME_COMMENT) + @javax.annotation.Nullable private String comment; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public CreateResourcePoolSnapshotPayload() {} + + public CreateResourcePoolSnapshotPayload comment(@javax.annotation.Nullable String comment) { + this.comment = comment; + return this; + } + + /** + * (optional) A comment to add more information about a snapshot + * + * @return comment + */ + @javax.annotation.Nullable public String getComment() { + return comment; + } + + public void setComment(@javax.annotation.Nullable String comment) { + this.comment = comment; + } + + public CreateResourcePoolSnapshotPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Resource Pool Snapshot + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateResourcePoolSnapshotPayload instance itself + */ + public CreateResourcePoolSnapshotPayload 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; + } + CreateResourcePoolSnapshotPayload createResourcePoolSnapshotPayload = + (CreateResourcePoolSnapshotPayload) o; + return Objects.equals(this.comment, createResourcePoolSnapshotPayload.comment) + && Objects.equals(this.name, createResourcePoolSnapshotPayload.name) + && Objects.equals( + this.additionalProperties, + createResourcePoolSnapshotPayload.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(comment, name, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateResourcePoolSnapshotPayload {\n"); + sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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("comment", "name")); + + // 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 + * CreateResourcePoolSnapshotPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateResourcePoolSnapshotPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateResourcePoolSnapshotPayload is not found in the empty JSON string", + CreateResourcePoolSnapshotPayload.openapiRequiredFields + .toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("comment") != null && !jsonObj.get("comment").isJsonNull()) + && !jsonObj.get("comment").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("comment").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateResourcePoolSnapshotPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateResourcePoolSnapshotPayload' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateResourcePoolSnapshotPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateResourcePoolSnapshotPayload 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 CreateResourcePoolSnapshotPayload read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateResourcePoolSnapshotPayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateResourcePoolSnapshotPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateResourcePoolSnapshotPayload + * @throws IOException if the JSON string is invalid with respect to + * CreateResourcePoolSnapshotPayload + */ + public static CreateResourcePoolSnapshotPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateResourcePoolSnapshotPayload.class); + } + + /** + * Convert an instance of CreateResourcePoolSnapshotPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotResponse.java new file mode 100644 index 0000000..8fbd49c --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateResourcePoolSnapshotResponse.java @@ -0,0 +1,306 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateResourcePoolSnapshotResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateResourcePoolSnapshotResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOT = "resourcePoolSnapshot"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOT) + @javax.annotation.Nullable private ResourcePoolSnapshot resourcePoolSnapshot; + + public CreateResourcePoolSnapshotResponse() {} + + public CreateResourcePoolSnapshotResponse resourcePoolSnapshot( + @javax.annotation.Nullable ResourcePoolSnapshot resourcePoolSnapshot) { + this.resourcePoolSnapshot = resourcePoolSnapshot; + return this; + } + + /** + * Created Resource Pool Snapshot + * + * @return resourcePoolSnapshot + */ + @javax.annotation.Nullable public ResourcePoolSnapshot getResourcePoolSnapshot() { + return resourcePoolSnapshot; + } + + public void setResourcePoolSnapshot( + @javax.annotation.Nullable ResourcePoolSnapshot resourcePoolSnapshot) { + this.resourcePoolSnapshot = resourcePoolSnapshot; + } + + /** + * 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 CreateResourcePoolSnapshotResponse instance itself + */ + public CreateResourcePoolSnapshotResponse 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; + } + CreateResourcePoolSnapshotResponse createResourcePoolSnapshotResponse = + (CreateResourcePoolSnapshotResponse) o; + return Objects.equals( + this.resourcePoolSnapshot, + createResourcePoolSnapshotResponse.resourcePoolSnapshot) + && Objects.equals( + this.additionalProperties, + createResourcePoolSnapshotResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePoolSnapshot, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateResourcePoolSnapshotResponse {\n"); + sb.append(" resourcePoolSnapshot: ") + .append(toIndentedString(resourcePoolSnapshot)) + .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("resourcePoolSnapshot")); + + // 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 + * CreateResourcePoolSnapshotResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateResourcePoolSnapshotResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateResourcePoolSnapshotResponse is not found in the empty JSON string", + CreateResourcePoolSnapshotResponse.openapiRequiredFields + .toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `resourcePoolSnapshot` + if (jsonObj.get("resourcePoolSnapshot") != null + && !jsonObj.get("resourcePoolSnapshot").isJsonNull()) { + ResourcePoolSnapshot.validateJsonElement(jsonObj.get("resourcePoolSnapshot")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateResourcePoolSnapshotResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateResourcePoolSnapshotResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateResourcePoolSnapshotResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateResourcePoolSnapshotResponse 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 CreateResourcePoolSnapshotResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateResourcePoolSnapshotResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateResourcePoolSnapshotResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateResourcePoolSnapshotResponse + * @throws IOException if the JSON string is invalid with respect to + * CreateResourcePoolSnapshotResponse + */ + public static CreateResourcePoolSnapshotResponse fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, CreateResourcePoolSnapshotResponse.class); + } + + /** + * Convert an instance of CreateResourcePoolSnapshotResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyPayload.java new file mode 100644 index 0000000..e88d472 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyPayload.java @@ -0,0 +1,394 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateShareExportPolicyPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateShareExportPolicyPayload { + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_RULES = "rules"; + + @SerializedName(SERIALIZED_NAME_RULES) + @javax.annotation.Nullable private List rules = new ArrayList<>(); + + public CreateShareExportPolicyPayload() {} + + public CreateShareExportPolicyPayload labels( + @javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateShareExportPolicyPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share export policy keys + * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and + * cannot be empty values are validated using the following regex + * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public CreateShareExportPolicyPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Share Export Policy + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public CreateShareExportPolicyPayload rules( + @javax.annotation.Nullable List rules) { + this.rules = rules; + return this; + } + + public CreateShareExportPolicyPayload addRulesItem( + CreateShareExportPolicyRequestRule rulesItem) { + if (this.rules == null) { + this.rules = new ArrayList<>(); + } + this.rules.add(rulesItem); + return this; + } + + /** + * List of rules of the Share Export Policy. The order of the rules within the array does not + * matter - what matters is the field \"order\" within each rule + * + * @return rules + */ + @javax.annotation.Nullable public List getRules() { + return rules; + } + + public void setRules( + @javax.annotation.Nullable List rules) { + this.rules = rules; + } + + /** + * 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 CreateShareExportPolicyPayload instance itself + */ + public CreateShareExportPolicyPayload 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; + } + CreateShareExportPolicyPayload createShareExportPolicyPayload = + (CreateShareExportPolicyPayload) o; + return Objects.equals(this.labels, createShareExportPolicyPayload.labels) + && Objects.equals(this.name, createShareExportPolicyPayload.name) + && Objects.equals(this.rules, createShareExportPolicyPayload.rules) + && Objects.equals( + this.additionalProperties, + createShareExportPolicyPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(labels, name, rules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateShareExportPolicyPayload {\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).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("labels", "name", "rules")); + + // 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 + * CreateShareExportPolicyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateShareExportPolicyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateShareExportPolicyPayload is not found in the empty JSON string", + CreateShareExportPolicyPayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (jsonObj.get("rules") != null && !jsonObj.get("rules").isJsonNull()) { + JsonArray jsonArrayrules = jsonObj.getAsJsonArray("rules"); + if (jsonArrayrules != null) { + // ensure the json data is an array + if (!jsonObj.get("rules").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `rules` to be an array in the JSON string but got `%s`", + jsonObj.get("rules").toString())); + } + + // validate the optional field `rules` (array) + for (int i = 0; i < jsonArrayrules.size(); i++) { + CreateShareExportPolicyRequestRule.validateJsonElement(jsonArrayrules.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateShareExportPolicyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateShareExportPolicyPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateShareExportPolicyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateShareExportPolicyPayload 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 CreateShareExportPolicyPayload read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateShareExportPolicyPayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateShareExportPolicyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateShareExportPolicyPayload + * @throws IOException if the JSON string is invalid with respect to + * CreateShareExportPolicyPayload + */ + public static CreateShareExportPolicyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateShareExportPolicyPayload.class); + } + + /** + * Convert an instance of CreateShareExportPolicyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyRequestRule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyRequestRule.java new file mode 100644 index 0000000..06d1e13 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyRequestRule.java @@ -0,0 +1,478 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** CreateShareExportPolicyRequestRule */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateShareExportPolicyRequestRule { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ORDER = "order"; + + @SerializedName(SERIALIZED_NAME_ORDER) + @javax.annotation.Nullable private Integer order; + + public static final String SERIALIZED_NAME_READ_ONLY = "readOnly"; + + @SerializedName(SERIALIZED_NAME_READ_ONLY) + @javax.annotation.Nullable private Boolean readOnly = false; + + public static final String SERIALIZED_NAME_SET_UUID = "setUuid"; + + @SerializedName(SERIALIZED_NAME_SET_UUID) + @javax.annotation.Nullable private Boolean setUuid = false; + + public static final String SERIALIZED_NAME_SUPER_USER = "superUser"; + + @SerializedName(SERIALIZED_NAME_SUPER_USER) + @javax.annotation.Nullable private Boolean superUser = true; + + public CreateShareExportPolicyRequestRule() {} + + public CreateShareExportPolicyRequestRule description( + @javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Description of the Rule (optional) + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public CreateShareExportPolicyRequestRule ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public CreateShareExportPolicyRequestRule addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * IP access control list, where IPs must have a subnet mask (e.g. \"172.16.0.0/24\" + * for a range of IPs, or \"172.16.0.250/32\" for a specific IP) This array cannot be + * empty + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public CreateShareExportPolicyRequestRule order(@javax.annotation.Nullable Integer order) { + this.order = order; + return this; + } + + /** + * Order of the rule within a Share Export Policy. The order is used so that when a client IP + * matches multiple rules, the first rule is applied This field must be set + * + * @return order + */ + @javax.annotation.Nullable public Integer getOrder() { + return order; + } + + public void setOrder(@javax.annotation.Nullable Integer order) { + this.order = order; + } + + public CreateShareExportPolicyRequestRule readOnly( + @javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule can only mount the share in read only mode + * Default: false + * + * @return readOnly + */ + @javax.annotation.Nullable public Boolean getReadOnly() { + return readOnly; + } + + public void setReadOnly(@javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + } + + public CreateShareExportPolicyRequestRule setUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + return this; + } + + /** + * Flag to honor set UUID Default: false + * + * @return setUuid + */ + @javax.annotation.Nullable public Boolean getSetUuid() { + return setUuid; + } + + public void setSetUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + } + + public CreateShareExportPolicyRequestRule superUser( + @javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule have root access on the Share Default: true + * + * @return superUser + */ + @javax.annotation.Nullable public Boolean getSuperUser() { + return superUser; + } + + public void setSuperUser(@javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + } + + /** + * 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 CreateShareExportPolicyRequestRule instance itself + */ + public CreateShareExportPolicyRequestRule 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; + } + CreateShareExportPolicyRequestRule createShareExportPolicyRequestRule = + (CreateShareExportPolicyRequestRule) o; + return Objects.equals(this.description, createShareExportPolicyRequestRule.description) + && Objects.equals(this.ipAcl, createShareExportPolicyRequestRule.ipAcl) + && Objects.equals(this.order, createShareExportPolicyRequestRule.order) + && Objects.equals(this.readOnly, createShareExportPolicyRequestRule.readOnly) + && Objects.equals(this.setUuid, createShareExportPolicyRequestRule.setUuid) + && Objects.equals(this.superUser, createShareExportPolicyRequestRule.superUser) + && Objects.equals( + this.additionalProperties, + createShareExportPolicyRequestRule.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + description, ipAcl, order, readOnly, setUuid, superUser, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateShareExportPolicyRequestRule {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" order: ").append(toIndentedString(order)).append("\n"); + sb.append(" readOnly: ").append(toIndentedString(readOnly)).append("\n"); + sb.append(" setUuid: ").append(toIndentedString(setUuid)).append("\n"); + sb.append(" superUser: ").append(toIndentedString(superUser)).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", + "ipAcl", + "order", + "readOnly", + "setUuid", + "superUser")); + + // 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 + * CreateShareExportPolicyRequestRule + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateShareExportPolicyRequestRule.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateShareExportPolicyRequestRule is not found in the empty JSON string", + CreateShareExportPolicyRequestRule.openapiRequiredFields + .toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateShareExportPolicyRequestRule.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateShareExportPolicyRequestRule' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateShareExportPolicyRequestRule.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateShareExportPolicyRequestRule 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 CreateShareExportPolicyRequestRule read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateShareExportPolicyRequestRule instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateShareExportPolicyRequestRule given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateShareExportPolicyRequestRule + * @throws IOException if the JSON string is invalid with respect to + * CreateShareExportPolicyRequestRule + */ + public static CreateShareExportPolicyRequestRule fromJson(String jsonString) + throws IOException { + return JSON.getGson().fromJson(jsonString, CreateShareExportPolicyRequestRule.class); + } + + /** + * Convert an instance of CreateShareExportPolicyRequestRule to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyResponse.java new file mode 100644 index 0000000..7370f66 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareExportPolicyResponse.java @@ -0,0 +1,303 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateShareExportPolicyResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateShareExportPolicyResponse { + public static final String SERIALIZED_NAME_SHARE_EXPORT_POLICY = "shareExportPolicy"; + + @SerializedName(SERIALIZED_NAME_SHARE_EXPORT_POLICY) + @javax.annotation.Nullable private ShareExportPolicy shareExportPolicy; + + public CreateShareExportPolicyResponse() {} + + public CreateShareExportPolicyResponse shareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + return this; + } + + /** + * Created Share Export Policy + * + * @return shareExportPolicy + */ + @javax.annotation.Nullable public ShareExportPolicy getShareExportPolicy() { + return shareExportPolicy; + } + + public void setShareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + } + + /** + * 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 CreateShareExportPolicyResponse instance itself + */ + public CreateShareExportPolicyResponse 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; + } + CreateShareExportPolicyResponse createShareExportPolicyResponse = + (CreateShareExportPolicyResponse) o; + return Objects.equals( + this.shareExportPolicy, createShareExportPolicyResponse.shareExportPolicy) + && Objects.equals( + this.additionalProperties, + createShareExportPolicyResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(shareExportPolicy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateShareExportPolicyResponse {\n"); + sb.append(" shareExportPolicy: ") + .append(toIndentedString(shareExportPolicy)) + .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("shareExportPolicy")); + + // 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 + * CreateShareExportPolicyResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateShareExportPolicyResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateShareExportPolicyResponse is not found in the empty JSON string", + CreateShareExportPolicyResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `shareExportPolicy` + if (jsonObj.get("shareExportPolicy") != null + && !jsonObj.get("shareExportPolicy").isJsonNull()) { + ShareExportPolicy.validateJsonElement(jsonObj.get("shareExportPolicy")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateShareExportPolicyResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateShareExportPolicyResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(CreateShareExportPolicyResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateShareExportPolicyResponse 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 CreateShareExportPolicyResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateShareExportPolicyResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateShareExportPolicyResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateShareExportPolicyResponse + * @throws IOException if the JSON string is invalid with respect to + * CreateShareExportPolicyResponse + */ + public static CreateShareExportPolicyResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateShareExportPolicyResponse.class); + } + + /** + * Convert an instance of CreateShareExportPolicyResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateSharePayload.java new file mode 100644 index 0000000..f218874 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateSharePayload.java @@ -0,0 +1,415 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** CreateSharePayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateSharePayload { + public static final String SERIALIZED_NAME_EXPORT_POLICY_NAME = "exportPolicyName"; + + @SerializedName(SERIALIZED_NAME_EXPORT_POLICY_NAME) + @javax.annotation.Nullable private String exportPolicyName; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES = + "spaceHardLimitGigabytes"; + + @SerializedName(SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES) + @javax.annotation.Nullable private Integer spaceHardLimitGigabytes; + + public CreateSharePayload() {} + + public CreateSharePayload exportPolicyName(@javax.annotation.Nullable String exportPolicyName) { + this.exportPolicyName = exportPolicyName; + return this; + } + + /** + * Name of the Share Export Policy to use in the Share. Note that if this is not set, the Share + * can only be mounted in read only by clients with IPs matching the IP ACL of the Resource Pool + * hosting this Share. You can also assign a Share Export Policy after creating the Share + * + * @return exportPolicyName + */ + @javax.annotation.Nullable public String getExportPolicyName() { + return exportPolicyName; + } + + public void setExportPolicyName(@javax.annotation.Nullable String exportPolicyName) { + this.exportPolicyName = exportPolicyName; + } + + public CreateSharePayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateSharePayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share keys are validated + * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty + * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public CreateSharePayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Share + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public CreateSharePayload spaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + return this; + } + + /** + * Space hard limit for the Share. If zero, the Share will have access to the full space of the + * Resource Pool it lives in. (unit: gibibytes) + * + * @return spaceHardLimitGigabytes + */ + @javax.annotation.Nullable public Integer getSpaceHardLimitGigabytes() { + return spaceHardLimitGigabytes; + } + + public void setSpaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + } + + /** + * 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 CreateSharePayload instance itself + */ + public CreateSharePayload 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; + } + CreateSharePayload createSharePayload = (CreateSharePayload) o; + return Objects.equals(this.exportPolicyName, createSharePayload.exportPolicyName) + && Objects.equals(this.labels, createSharePayload.labels) + && Objects.equals(this.name, createSharePayload.name) + && Objects.equals( + this.spaceHardLimitGigabytes, createSharePayload.spaceHardLimitGigabytes) + && Objects.equals( + this.additionalProperties, createSharePayload.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + exportPolicyName, labels, name, spaceHardLimitGigabytes, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateSharePayload {\n"); + sb.append(" exportPolicyName: ").append(toIndentedString(exportPolicyName)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" spaceHardLimitGigabytes: ") + .append(toIndentedString(spaceHardLimitGigabytes)) + .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( + "exportPolicyName", "labels", "name", "spaceHardLimitGigabytes")); + + // 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 CreateSharePayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateSharePayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateSharePayload is not found in the empty JSON string", + CreateSharePayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("exportPolicyName") != null + && !jsonObj.get("exportPolicyName").isJsonNull()) + && !jsonObj.get("exportPolicyName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `exportPolicyName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("exportPolicyName").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateSharePayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateSharePayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateSharePayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateSharePayload 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 CreateSharePayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateSharePayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateSharePayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateSharePayload + * @throws IOException if the JSON string is invalid with respect to CreateSharePayload + */ + public static CreateSharePayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateSharePayload.class); + } + + /** + * Convert an instance of CreateSharePayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareResponse.java new file mode 100644 index 0000000..60665ae --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/CreateShareResponse.java @@ -0,0 +1,289 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** CreateShareResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateShareResponse { + public static final String SERIALIZED_NAME_SHARE = "share"; + + @SerializedName(SERIALIZED_NAME_SHARE) + @javax.annotation.Nullable private Share share; + + public CreateShareResponse() {} + + public CreateShareResponse share(@javax.annotation.Nullable Share share) { + this.share = share; + return this; + } + + /** + * Created Share + * + * @return share + */ + @javax.annotation.Nullable public Share getShare() { + return share; + } + + public void setShare(@javax.annotation.Nullable Share share) { + this.share = share; + } + + /** + * 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 CreateShareResponse instance itself + */ + public CreateShareResponse 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; + } + CreateShareResponse createShareResponse = (CreateShareResponse) o; + return Objects.equals(this.share, createShareResponse.share) + && Objects.equals( + this.additionalProperties, createShareResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(share, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateShareResponse {\n"); + sb.append(" share: ").append(toIndentedString(share)).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("share")); + + // 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 CreateShareResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateShareResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateShareResponse is not found in the empty JSON string", + CreateShareResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `share` + if (jsonObj.get("share") != null && !jsonObj.get("share").isJsonNull()) { + Share.validateJsonElement(jsonObj.get("share")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateShareResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateShareResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateShareResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateShareResponse 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 CreateShareResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateShareResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateShareResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateShareResponse + * @throws IOException if the JSON string is invalid with respect to CreateShareResponse + */ + public static CreateShareResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateShareResponse.class); + } + + /** + * Convert an instance of CreateShareResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Error.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Error.java new file mode 100644 index 0000000..af182c6 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Error.java @@ -0,0 +1,382 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** Error */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Error { + public static final String SERIALIZED_NAME_ERROR_DESCRIPTION = "error_description"; + + @Deprecated + @SerializedName(SERIALIZED_NAME_ERROR_DESCRIPTION) + @javax.annotation.Nullable private Object errorDescription = null; + + public static final String SERIALIZED_NAME_TITLE = "title"; + + @SerializedName(SERIALIZED_NAME_TITLE) + @javax.annotation.Nonnull + private String title; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public Error() {} + + @Deprecated + public Error errorDescription(@javax.annotation.Nullable Object errorDescription) { + this.errorDescription = errorDescription; + return this; + } + + /** + * Human-readable string of the error that occured + * + * @return errorDescription + * @deprecated + */ + @Deprecated + @javax.annotation.Nullable public Object getErrorDescription() { + return errorDescription; + } + + @Deprecated + public void setErrorDescription(@javax.annotation.Nullable Object errorDescription) { + this.errorDescription = errorDescription; + } + + public Error title(@javax.annotation.Nonnull String title) { + this.title = title; + return this; + } + + /** + * Human-readable description of the error that occurred. + * + * @return title + */ + @javax.annotation.Nonnull + public String getTitle() { + return title; + } + + public void setTitle(@javax.annotation.Nonnull String title) { + this.title = title; + } + + public Error type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * URI Uniquely identifies the error type. It will be in the format of + * storage.stackit.cloud/<error-type> e.g. storage.stackit.cloud/validation-error + * + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Error instance itself + */ + public Error 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; + } + Error error = (Error) o; + return Objects.equals(this.errorDescription, error.errorDescription) + && Objects.equals(this.title, error.title) + && Objects.equals(this.type, error.type) + && Objects.equals(this.additionalProperties, error.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(errorDescription, title, type, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error {\n"); + sb.append(" errorDescription: ").append(toIndentedString(errorDescription)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("error_description", "title", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("title", "type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Error + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Error.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Error is not found in the empty JSON string", + Error.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Error.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `title` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("title").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Error.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Error' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Error.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Error 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 Error read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Error instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of Error given an JSON string + * + * @param jsonString JSON string + * @return An instance of Error + * @throws IOException if the JSON string is invalid with respect to Error + */ + public static Error fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Error.class); + } + + /** + * Convert an instance of Error to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolResponse.java new file mode 100644 index 0000000..b4b8aac --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolResponse.java @@ -0,0 +1,291 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** GetResourcePoolResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetResourcePoolResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL = "resourcePool"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL) + @javax.annotation.Nullable private ResourcePool resourcePool; + + public GetResourcePoolResponse() {} + + public GetResourcePoolResponse resourcePool( + @javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + return this; + } + + /** + * Resource Pool + * + * @return resourcePool + */ + @javax.annotation.Nullable public ResourcePool getResourcePool() { + return resourcePool; + } + + public void setResourcePool(@javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + } + + /** + * 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 GetResourcePoolResponse instance itself + */ + public GetResourcePoolResponse 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; + } + GetResourcePoolResponse getResourcePoolResponse = (GetResourcePoolResponse) o; + return Objects.equals(this.resourcePool, getResourcePoolResponse.resourcePool) + && Objects.equals( + this.additionalProperties, getResourcePoolResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePool, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetResourcePoolResponse {\n"); + sb.append(" resourcePool: ").append(toIndentedString(resourcePool)).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("resourcePool")); + + // 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 GetResourcePoolResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetResourcePoolResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetResourcePoolResponse is not found in the empty JSON string", + GetResourcePoolResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `resourcePool` + if (jsonObj.get("resourcePool") != null && !jsonObj.get("resourcePool").isJsonNull()) { + ResourcePool.validateJsonElement(jsonObj.get("resourcePool")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetResourcePoolResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetResourcePoolResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetResourcePoolResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetResourcePoolResponse 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 GetResourcePoolResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetResourcePoolResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetResourcePoolResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetResourcePoolResponse + * @throws IOException if the JSON string is invalid with respect to GetResourcePoolResponse + */ + public static GetResourcePoolResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetResourcePoolResponse.class); + } + + /** + * Convert an instance of GetResourcePoolResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolSnapshotResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolSnapshotResponse.java new file mode 100644 index 0000000..eb175eb --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetResourcePoolSnapshotResponse.java @@ -0,0 +1,304 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** GetResourcePoolSnapshotResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetResourcePoolSnapshotResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOT = "resourcePoolSnapshot"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOT) + @javax.annotation.Nullable private ResourcePoolSnapshot resourcePoolSnapshot; + + public GetResourcePoolSnapshotResponse() {} + + public GetResourcePoolSnapshotResponse resourcePoolSnapshot( + @javax.annotation.Nullable ResourcePoolSnapshot resourcePoolSnapshot) { + this.resourcePoolSnapshot = resourcePoolSnapshot; + return this; + } + + /** + * Resource Pool Snapshot + * + * @return resourcePoolSnapshot + */ + @javax.annotation.Nullable public ResourcePoolSnapshot getResourcePoolSnapshot() { + return resourcePoolSnapshot; + } + + public void setResourcePoolSnapshot( + @javax.annotation.Nullable ResourcePoolSnapshot resourcePoolSnapshot) { + this.resourcePoolSnapshot = resourcePoolSnapshot; + } + + /** + * 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 GetResourcePoolSnapshotResponse instance itself + */ + public GetResourcePoolSnapshotResponse 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; + } + GetResourcePoolSnapshotResponse getResourcePoolSnapshotResponse = + (GetResourcePoolSnapshotResponse) o; + return Objects.equals( + this.resourcePoolSnapshot, + getResourcePoolSnapshotResponse.resourcePoolSnapshot) + && Objects.equals( + this.additionalProperties, + getResourcePoolSnapshotResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePoolSnapshot, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetResourcePoolSnapshotResponse {\n"); + sb.append(" resourcePoolSnapshot: ") + .append(toIndentedString(resourcePoolSnapshot)) + .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("resourcePoolSnapshot")); + + // 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 + * GetResourcePoolSnapshotResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetResourcePoolSnapshotResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetResourcePoolSnapshotResponse is not found in the empty JSON string", + GetResourcePoolSnapshotResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `resourcePoolSnapshot` + if (jsonObj.get("resourcePoolSnapshot") != null + && !jsonObj.get("resourcePoolSnapshot").isJsonNull()) { + ResourcePoolSnapshot.validateJsonElement(jsonObj.get("resourcePoolSnapshot")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetResourcePoolSnapshotResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetResourcePoolSnapshotResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(GetResourcePoolSnapshotResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetResourcePoolSnapshotResponse 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 GetResourcePoolSnapshotResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetResourcePoolSnapshotResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetResourcePoolSnapshotResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetResourcePoolSnapshotResponse + * @throws IOException if the JSON string is invalid with respect to + * GetResourcePoolSnapshotResponse + */ + public static GetResourcePoolSnapshotResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetResourcePoolSnapshotResponse.class); + } + + /** + * Convert an instance of GetResourcePoolSnapshotResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareExportPolicyResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareExportPolicyResponse.java new file mode 100644 index 0000000..dd99360 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareExportPolicyResponse.java @@ -0,0 +1,302 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** GetShareExportPolicyResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetShareExportPolicyResponse { + public static final String SERIALIZED_NAME_SHARE_EXPORT_POLICY = "shareExportPolicy"; + + @SerializedName(SERIALIZED_NAME_SHARE_EXPORT_POLICY) + @javax.annotation.Nullable private ShareExportPolicy shareExportPolicy; + + public GetShareExportPolicyResponse() {} + + public GetShareExportPolicyResponse shareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + return this; + } + + /** + * Share Export Policies + * + * @return shareExportPolicy + */ + @javax.annotation.Nullable public ShareExportPolicy getShareExportPolicy() { + return shareExportPolicy; + } + + public void setShareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + } + + /** + * 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 GetShareExportPolicyResponse instance itself + */ + public GetShareExportPolicyResponse 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; + } + GetShareExportPolicyResponse getShareExportPolicyResponse = + (GetShareExportPolicyResponse) o; + return Objects.equals( + this.shareExportPolicy, getShareExportPolicyResponse.shareExportPolicy) + && Objects.equals( + this.additionalProperties, + getShareExportPolicyResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(shareExportPolicy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetShareExportPolicyResponse {\n"); + sb.append(" shareExportPolicy: ") + .append(toIndentedString(shareExportPolicy)) + .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("shareExportPolicy")); + + // 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 + * GetShareExportPolicyResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetShareExportPolicyResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetShareExportPolicyResponse is not found in the empty JSON string", + GetShareExportPolicyResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `shareExportPolicy` + if (jsonObj.get("shareExportPolicy") != null + && !jsonObj.get("shareExportPolicy").isJsonNull()) { + ShareExportPolicy.validateJsonElement(jsonObj.get("shareExportPolicy")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetShareExportPolicyResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetShareExportPolicyResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(GetShareExportPolicyResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetShareExportPolicyResponse 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 GetShareExportPolicyResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetShareExportPolicyResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetShareExportPolicyResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetShareExportPolicyResponse + * @throws IOException if the JSON string is invalid with respect to + * GetShareExportPolicyResponse + */ + public static GetShareExportPolicyResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetShareExportPolicyResponse.class); + } + + /** + * Convert an instance of GetShareExportPolicyResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareResponse.java new file mode 100644 index 0000000..e22d8ae --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GetShareResponse.java @@ -0,0 +1,288 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** GetShareResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetShareResponse { + public static final String SERIALIZED_NAME_SHARE = "share"; + + @SerializedName(SERIALIZED_NAME_SHARE) + @javax.annotation.Nullable private Share share; + + public GetShareResponse() {} + + public GetShareResponse share(@javax.annotation.Nullable Share share) { + this.share = share; + return this; + } + + /** + * Share + * + * @return share + */ + @javax.annotation.Nullable public Share getShare() { + return share; + } + + public void setShare(@javax.annotation.Nullable Share share) { + this.share = share; + } + + /** + * 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 GetShareResponse instance itself + */ + public GetShareResponse 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; + } + GetShareResponse getShareResponse = (GetShareResponse) o; + return Objects.equals(this.share, getShareResponse.share) + && Objects.equals(this.additionalProperties, getShareResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(share, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetShareResponse {\n"); + sb.append(" share: ").append(toIndentedString(share)).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("share")); + + // 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 GetShareResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetShareResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetShareResponse is not found in the empty JSON string", + GetShareResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `share` + if (jsonObj.get("share") != null && !jsonObj.get("share").isJsonNull()) { + Share.validateJsonElement(jsonObj.get("share")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetShareResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetShareResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetShareResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetShareResponse 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 GetShareResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GetShareResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetShareResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetShareResponse + * @throws IOException if the JSON string is invalid with respect to GetShareResponse + */ + public static GetShareResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetShareResponse.class); + } + + /** + * Convert an instance of GetShareResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GoogleProtobufAny.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GoogleProtobufAny.java new file mode 100644 index 0000000..b66e040 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/GoogleProtobufAny.java @@ -0,0 +1,295 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** + * Contains an arbitrary serialized message along with a @type that describes the type of the + * serialized message. + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GoogleProtobufAny { + public static final String SERIALIZED_NAME_AT_TYPE = "@type"; + + @SerializedName(SERIALIZED_NAME_AT_TYPE) + @javax.annotation.Nullable private String atType; + + public GoogleProtobufAny() {} + + public GoogleProtobufAny atType(@javax.annotation.Nullable String atType) { + this.atType = atType; + return this; + } + + /** + * The type of the serialized message. + * + * @return atType + */ + @javax.annotation.Nullable public String getAtType() { + return atType; + } + + public void setAtType(@javax.annotation.Nullable String atType) { + this.atType = atType; + } + + /** + * 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 GoogleProtobufAny instance itself + */ + public GoogleProtobufAny 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; + } + GoogleProtobufAny googleProtobufAny = (GoogleProtobufAny) o; + return Objects.equals(this.atType, googleProtobufAny.atType) + && Objects.equals( + this.additionalProperties, googleProtobufAny.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(atType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GoogleProtobufAny {\n"); + sb.append(" atType: ").append(toIndentedString(atType)).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")); + + // 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 GoogleProtobufAny + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GoogleProtobufAny.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GoogleProtobufAny is not found in the empty JSON string", + GoogleProtobufAny.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("@type") != null && !jsonObj.get("@type").isJsonNull()) + && !jsonObj.get("@type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `@type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("@type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GoogleProtobufAny.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GoogleProtobufAny' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GoogleProtobufAny.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GoogleProtobufAny 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 GoogleProtobufAny read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GoogleProtobufAny instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GoogleProtobufAny given an JSON string + * + * @param jsonString JSON string + * @return An instance of GoogleProtobufAny + * @throws IOException if the JSON string is invalid with respect to GoogleProtobufAny + */ + public static GoogleProtobufAny fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GoogleProtobufAny.class); + } + + /** + * Convert an instance of GoogleProtobufAny to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListPerformanceClassesResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListPerformanceClassesResponse.java new file mode 100644 index 0000000..f34de43 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListPerformanceClassesResponse.java @@ -0,0 +1,328 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListPerformanceClassesResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListPerformanceClassesResponse { + public static final String SERIALIZED_NAME_PERFORMANCE_CLASSES = "performanceClasses"; + + @SerializedName(SERIALIZED_NAME_PERFORMANCE_CLASSES) + @javax.annotation.Nullable private List performanceClasses = new ArrayList<>(); + + public ListPerformanceClassesResponse() {} + + public ListPerformanceClassesResponse performanceClasses( + @javax.annotation.Nullable List performanceClasses) { + this.performanceClasses = performanceClasses; + return this; + } + + public ListPerformanceClassesResponse addPerformanceClassesItem( + PerformanceClass performanceClassesItem) { + if (this.performanceClasses == null) { + this.performanceClasses = new ArrayList<>(); + } + this.performanceClasses.add(performanceClassesItem); + return this; + } + + /** + * List of Performance Classes + * + * @return performanceClasses + */ + @javax.annotation.Nullable public List getPerformanceClasses() { + return performanceClasses; + } + + public void setPerformanceClasses( + @javax.annotation.Nullable List performanceClasses) { + this.performanceClasses = performanceClasses; + } + + /** + * 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 ListPerformanceClassesResponse instance itself + */ + public ListPerformanceClassesResponse 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; + } + ListPerformanceClassesResponse listPerformanceClassesResponse = + (ListPerformanceClassesResponse) o; + return Objects.equals( + this.performanceClasses, listPerformanceClassesResponse.performanceClasses) + && Objects.equals( + this.additionalProperties, + listPerformanceClassesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(performanceClasses, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListPerformanceClassesResponse {\n"); + sb.append(" performanceClasses: ") + .append(toIndentedString(performanceClasses)) + .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("performanceClasses")); + + // 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 + * ListPerformanceClassesResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListPerformanceClassesResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListPerformanceClassesResponse is not found in the empty JSON string", + ListPerformanceClassesResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("performanceClasses") != null + && !jsonObj.get("performanceClasses").isJsonNull()) { + JsonArray jsonArrayperformanceClasses = jsonObj.getAsJsonArray("performanceClasses"); + if (jsonArrayperformanceClasses != null) { + // ensure the json data is an array + if (!jsonObj.get("performanceClasses").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `performanceClasses` to be an array in the JSON string but got `%s`", + jsonObj.get("performanceClasses").toString())); + } + + // validate the optional field `performanceClasses` (array) + for (int i = 0; i < jsonArrayperformanceClasses.size(); i++) { + PerformanceClass.validateJsonElement(jsonArrayperformanceClasses.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListPerformanceClassesResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListPerformanceClassesResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ListPerformanceClassesResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListPerformanceClassesResponse 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 ListPerformanceClassesResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListPerformanceClassesResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListPerformanceClassesResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListPerformanceClassesResponse + * @throws IOException if the JSON string is invalid with respect to + * ListPerformanceClassesResponse + */ + public static ListPerformanceClassesResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListPerformanceClassesResponse.class); + } + + /** + * Convert an instance of ListPerformanceClassesResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolSnapshotsResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolSnapshotsResponse.java new file mode 100644 index 0000000..054330a --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolSnapshotsResponse.java @@ -0,0 +1,331 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListResourcePoolSnapshotsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListResourcePoolSnapshotsResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOTS = "resourcePoolSnapshots"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL_SNAPSHOTS) + @javax.annotation.Nullable private List resourcePoolSnapshots = new ArrayList<>(); + + public ListResourcePoolSnapshotsResponse() {} + + public ListResourcePoolSnapshotsResponse resourcePoolSnapshots( + @javax.annotation.Nullable List resourcePoolSnapshots) { + this.resourcePoolSnapshots = resourcePoolSnapshots; + return this; + } + + public ListResourcePoolSnapshotsResponse addResourcePoolSnapshotsItem( + ResourcePoolSnapshot resourcePoolSnapshotsItem) { + if (this.resourcePoolSnapshots == null) { + this.resourcePoolSnapshots = new ArrayList<>(); + } + this.resourcePoolSnapshots.add(resourcePoolSnapshotsItem); + return this; + } + + /** + * List of Resource Pool Snapshots + * + * @return resourcePoolSnapshots + */ + @javax.annotation.Nullable public List getResourcePoolSnapshots() { + return resourcePoolSnapshots; + } + + public void setResourcePoolSnapshots( + @javax.annotation.Nullable List resourcePoolSnapshots) { + this.resourcePoolSnapshots = resourcePoolSnapshots; + } + + /** + * 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 ListResourcePoolSnapshotsResponse instance itself + */ + public ListResourcePoolSnapshotsResponse 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; + } + ListResourcePoolSnapshotsResponse listResourcePoolSnapshotsResponse = + (ListResourcePoolSnapshotsResponse) o; + return Objects.equals( + this.resourcePoolSnapshots, + listResourcePoolSnapshotsResponse.resourcePoolSnapshots) + && Objects.equals( + this.additionalProperties, + listResourcePoolSnapshotsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePoolSnapshots, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListResourcePoolSnapshotsResponse {\n"); + sb.append(" resourcePoolSnapshots: ") + .append(toIndentedString(resourcePoolSnapshots)) + .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("resourcePoolSnapshots")); + + // 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 + * ListResourcePoolSnapshotsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListResourcePoolSnapshotsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListResourcePoolSnapshotsResponse is not found in the empty JSON string", + ListResourcePoolSnapshotsResponse.openapiRequiredFields + .toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("resourcePoolSnapshots") != null + && !jsonObj.get("resourcePoolSnapshots").isJsonNull()) { + JsonArray jsonArrayresourcePoolSnapshots = + jsonObj.getAsJsonArray("resourcePoolSnapshots"); + if (jsonArrayresourcePoolSnapshots != null) { + // ensure the json data is an array + if (!jsonObj.get("resourcePoolSnapshots").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `resourcePoolSnapshots` to be an array in the JSON string but got `%s`", + jsonObj.get("resourcePoolSnapshots").toString())); + } + + // validate the optional field `resourcePoolSnapshots` (array) + for (int i = 0; i < jsonArrayresourcePoolSnapshots.size(); i++) { + ResourcePoolSnapshot.validateJsonElement(jsonArrayresourcePoolSnapshots.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListResourcePoolSnapshotsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListResourcePoolSnapshotsResponse' and + // its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ListResourcePoolSnapshotsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListResourcePoolSnapshotsResponse 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 ListResourcePoolSnapshotsResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListResourcePoolSnapshotsResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListResourcePoolSnapshotsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListResourcePoolSnapshotsResponse + * @throws IOException if the JSON string is invalid with respect to + * ListResourcePoolSnapshotsResponse + */ + public static ListResourcePoolSnapshotsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListResourcePoolSnapshotsResponse.class); + } + + /** + * Convert an instance of ListResourcePoolSnapshotsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolsResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolsResponse.java new file mode 100644 index 0000000..859a366 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListResourcePoolsResponse.java @@ -0,0 +1,315 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListResourcePoolsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListResourcePoolsResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOLS = "resourcePools"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOLS) + @javax.annotation.Nullable private List resourcePools = new ArrayList<>(); + + public ListResourcePoolsResponse() {} + + public ListResourcePoolsResponse resourcePools( + @javax.annotation.Nullable List resourcePools) { + this.resourcePools = resourcePools; + return this; + } + + public ListResourcePoolsResponse addResourcePoolsItem(ResourcePool resourcePoolsItem) { + if (this.resourcePools == null) { + this.resourcePools = new ArrayList<>(); + } + this.resourcePools.add(resourcePoolsItem); + return this; + } + + /** + * List of Resource Pools + * + * @return resourcePools + */ + @javax.annotation.Nullable public List getResourcePools() { + return resourcePools; + } + + public void setResourcePools(@javax.annotation.Nullable List resourcePools) { + this.resourcePools = resourcePools; + } + + /** + * 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 ListResourcePoolsResponse instance itself + */ + public ListResourcePoolsResponse 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; + } + ListResourcePoolsResponse listResourcePoolsResponse = (ListResourcePoolsResponse) o; + return Objects.equals(this.resourcePools, listResourcePoolsResponse.resourcePools) + && Objects.equals( + this.additionalProperties, listResourcePoolsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePools, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListResourcePoolsResponse {\n"); + sb.append(" resourcePools: ").append(toIndentedString(resourcePools)).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("resourcePools")); + + // 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 ListResourcePoolsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListResourcePoolsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListResourcePoolsResponse is not found in the empty JSON string", + ListResourcePoolsResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("resourcePools") != null && !jsonObj.get("resourcePools").isJsonNull()) { + JsonArray jsonArrayresourcePools = jsonObj.getAsJsonArray("resourcePools"); + if (jsonArrayresourcePools != null) { + // ensure the json data is an array + if (!jsonObj.get("resourcePools").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `resourcePools` to be an array in the JSON string but got `%s`", + jsonObj.get("resourcePools").toString())); + } + + // validate the optional field `resourcePools` (array) + for (int i = 0; i < jsonArrayresourcePools.size(); i++) { + ResourcePool.validateJsonElement(jsonArrayresourcePools.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListResourcePoolsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListResourcePoolsResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListResourcePoolsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListResourcePoolsResponse 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 ListResourcePoolsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListResourcePoolsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListResourcePoolsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListResourcePoolsResponse + * @throws IOException if the JSON string is invalid with respect to ListResourcePoolsResponse + */ + public static ListResourcePoolsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListResourcePoolsResponse.class); + } + + /** + * Convert an instance of ListResourcePoolsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListShareExportPoliciesResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListShareExportPoliciesResponse.java new file mode 100644 index 0000000..b331c74 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListShareExportPoliciesResponse.java @@ -0,0 +1,329 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListShareExportPoliciesResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListShareExportPoliciesResponse { + public static final String SERIALIZED_NAME_SHARE_EXPORT_POLICIES = "shareExportPolicies"; + + @SerializedName(SERIALIZED_NAME_SHARE_EXPORT_POLICIES) + @javax.annotation.Nullable private List shareExportPolicies = new ArrayList<>(); + + public ListShareExportPoliciesResponse() {} + + public ListShareExportPoliciesResponse shareExportPolicies( + @javax.annotation.Nullable List shareExportPolicies) { + this.shareExportPolicies = shareExportPolicies; + return this; + } + + public ListShareExportPoliciesResponse addShareExportPoliciesItem( + ShareExportPolicy shareExportPoliciesItem) { + if (this.shareExportPolicies == null) { + this.shareExportPolicies = new ArrayList<>(); + } + this.shareExportPolicies.add(shareExportPoliciesItem); + return this; + } + + /** + * List of Share Export Policies + * + * @return shareExportPolicies + */ + @javax.annotation.Nullable public List getShareExportPolicies() { + return shareExportPolicies; + } + + public void setShareExportPolicies( + @javax.annotation.Nullable List shareExportPolicies) { + this.shareExportPolicies = shareExportPolicies; + } + + /** + * 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 ListShareExportPoliciesResponse instance itself + */ + public ListShareExportPoliciesResponse 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; + } + ListShareExportPoliciesResponse listShareExportPoliciesResponse = + (ListShareExportPoliciesResponse) o; + return Objects.equals( + this.shareExportPolicies, + listShareExportPoliciesResponse.shareExportPolicies) + && Objects.equals( + this.additionalProperties, + listShareExportPoliciesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(shareExportPolicies, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListShareExportPoliciesResponse {\n"); + sb.append(" shareExportPolicies: ") + .append(toIndentedString(shareExportPolicies)) + .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("shareExportPolicies")); + + // 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 + * ListShareExportPoliciesResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListShareExportPoliciesResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListShareExportPoliciesResponse is not found in the empty JSON string", + ListShareExportPoliciesResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("shareExportPolicies") != null + && !jsonObj.get("shareExportPolicies").isJsonNull()) { + JsonArray jsonArrayshareExportPolicies = jsonObj.getAsJsonArray("shareExportPolicies"); + if (jsonArrayshareExportPolicies != null) { + // ensure the json data is an array + if (!jsonObj.get("shareExportPolicies").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `shareExportPolicies` to be an array in the JSON string but got `%s`", + jsonObj.get("shareExportPolicies").toString())); + } + + // validate the optional field `shareExportPolicies` (array) + for (int i = 0; i < jsonArrayshareExportPolicies.size(); i++) { + ShareExportPolicy.validateJsonElement(jsonArrayshareExportPolicies.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListShareExportPoliciesResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListShareExportPoliciesResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ListShareExportPoliciesResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListShareExportPoliciesResponse 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 ListShareExportPoliciesResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListShareExportPoliciesResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListShareExportPoliciesResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListShareExportPoliciesResponse + * @throws IOException if the JSON string is invalid with respect to + * ListShareExportPoliciesResponse + */ + public static ListShareExportPoliciesResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListShareExportPoliciesResponse.class); + } + + /** + * Convert an instance of ListShareExportPoliciesResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSharesResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSharesResponse.java new file mode 100644 index 0000000..fafa61d --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSharesResponse.java @@ -0,0 +1,313 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListSharesResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListSharesResponse { + public static final String SERIALIZED_NAME_SHARES = "shares"; + + @SerializedName(SERIALIZED_NAME_SHARES) + @javax.annotation.Nullable private List shares = new ArrayList<>(); + + public ListSharesResponse() {} + + public ListSharesResponse shares(@javax.annotation.Nullable List shares) { + this.shares = shares; + return this; + } + + public ListSharesResponse addSharesItem(Share sharesItem) { + if (this.shares == null) { + this.shares = new ArrayList<>(); + } + this.shares.add(sharesItem); + return this; + } + + /** + * List of Shares + * + * @return shares + */ + @javax.annotation.Nullable public List getShares() { + return shares; + } + + public void setShares(@javax.annotation.Nullable List shares) { + this.shares = shares; + } + + /** + * 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 ListSharesResponse instance itself + */ + public ListSharesResponse 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; + } + ListSharesResponse listSharesResponse = (ListSharesResponse) o; + return Objects.equals(this.shares, listSharesResponse.shares) + && Objects.equals( + this.additionalProperties, listSharesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(shares, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListSharesResponse {\n"); + sb.append(" shares: ").append(toIndentedString(shares)).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("shares")); + + // 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 ListSharesResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListSharesResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListSharesResponse is not found in the empty JSON string", + ListSharesResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("shares") != null && !jsonObj.get("shares").isJsonNull()) { + JsonArray jsonArrayshares = jsonObj.getAsJsonArray("shares"); + if (jsonArrayshares != null) { + // ensure the json data is an array + if (!jsonObj.get("shares").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `shares` to be an array in the JSON string but got `%s`", + jsonObj.get("shares").toString())); + } + + // validate the optional field `shares` (array) + for (int i = 0; i < jsonArrayshares.size(); i++) { + Share.validateJsonElement(jsonArrayshares.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListSharesResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListSharesResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListSharesResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListSharesResponse 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 ListSharesResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListSharesResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListSharesResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListSharesResponse + * @throws IOException if the JSON string is invalid with respect to ListSharesResponse + */ + public static ListSharesResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListSharesResponse.class); + } + + /** + * Convert an instance of ListSharesResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSnapshotSchedulesResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSnapshotSchedulesResponse.java new file mode 100644 index 0000000..70df632 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ListSnapshotSchedulesResponse.java @@ -0,0 +1,328 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ListSnapshotSchedulesResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListSnapshotSchedulesResponse { + public static final String SERIALIZED_NAME_SNAPSHOT_SCHEDULES = "snapshotSchedules"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_SCHEDULES) + @javax.annotation.Nullable private List snapshotSchedules = new ArrayList<>(); + + public ListSnapshotSchedulesResponse() {} + + public ListSnapshotSchedulesResponse snapshotSchedules( + @javax.annotation.Nullable List snapshotSchedules) { + this.snapshotSchedules = snapshotSchedules; + return this; + } + + public ListSnapshotSchedulesResponse addSnapshotSchedulesItem( + SnapshotSchedule snapshotSchedulesItem) { + if (this.snapshotSchedules == null) { + this.snapshotSchedules = new ArrayList<>(); + } + this.snapshotSchedules.add(snapshotSchedulesItem); + return this; + } + + /** + * List of Snapshot Schedules + * + * @return snapshotSchedules + */ + @javax.annotation.Nullable public List getSnapshotSchedules() { + return snapshotSchedules; + } + + public void setSnapshotSchedules( + @javax.annotation.Nullable List snapshotSchedules) { + this.snapshotSchedules = snapshotSchedules; + } + + /** + * 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 ListSnapshotSchedulesResponse instance itself + */ + public ListSnapshotSchedulesResponse 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; + } + ListSnapshotSchedulesResponse listSnapshotSchedulesResponse = + (ListSnapshotSchedulesResponse) o; + return Objects.equals( + this.snapshotSchedules, listSnapshotSchedulesResponse.snapshotSchedules) + && Objects.equals( + this.additionalProperties, + listSnapshotSchedulesResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(snapshotSchedules, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListSnapshotSchedulesResponse {\n"); + sb.append(" snapshotSchedules: ") + .append(toIndentedString(snapshotSchedules)) + .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("snapshotSchedules")); + + // 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 + * ListSnapshotSchedulesResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListSnapshotSchedulesResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListSnapshotSchedulesResponse is not found in the empty JSON string", + ListSnapshotSchedulesResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("snapshotSchedules") != null + && !jsonObj.get("snapshotSchedules").isJsonNull()) { + JsonArray jsonArraysnapshotSchedules = jsonObj.getAsJsonArray("snapshotSchedules"); + if (jsonArraysnapshotSchedules != null) { + // ensure the json data is an array + if (!jsonObj.get("snapshotSchedules").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `snapshotSchedules` to be an array in the JSON string but got `%s`", + jsonObj.get("snapshotSchedules").toString())); + } + + // validate the optional field `snapshotSchedules` (array) + for (int i = 0; i < jsonArraysnapshotSchedules.size(); i++) { + SnapshotSchedule.validateJsonElement(jsonArraysnapshotSchedules.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListSnapshotSchedulesResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListSnapshotSchedulesResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ListSnapshotSchedulesResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListSnapshotSchedulesResponse 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 ListSnapshotSchedulesResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListSnapshotSchedulesResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListSnapshotSchedulesResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListSnapshotSchedulesResponse + * @throws IOException if the JSON string is invalid with respect to + * ListSnapshotSchedulesResponse + */ + public static ListSnapshotSchedulesResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListSnapshotSchedulesResponse.class); + } + + /** + * Convert an instance of ListSnapshotSchedulesResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/PerformanceClass.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/PerformanceClass.java new file mode 100644 index 0000000..8a1cb3c --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/PerformanceClass.java @@ -0,0 +1,341 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** PerformanceClass */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class PerformanceClass { + public static final String SERIALIZED_NAME_IOPS = "iops"; + + @SerializedName(SERIALIZED_NAME_IOPS) + @javax.annotation.Nullable private Integer iops; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_THROUGHPUT = "throughput"; + + @SerializedName(SERIALIZED_NAME_THROUGHPUT) + @javax.annotation.Nullable private Integer throughput; + + public PerformanceClass() {} + + public PerformanceClass iops(@javax.annotation.Nullable Integer iops) { + this.iops = iops; + return this; + } + + /** + * IOPS of the Performance Class + * + * @return iops + */ + @javax.annotation.Nullable public Integer getIops() { + return iops; + } + + public void setIops(@javax.annotation.Nullable Integer iops) { + this.iops = iops; + } + + public PerformanceClass name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Performance Class + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public PerformanceClass throughput(@javax.annotation.Nullable Integer throughput) { + this.throughput = throughput; + return this; + } + + /** + * Throughput of the Performance Class + * + * @return throughput + */ + @javax.annotation.Nullable public Integer getThroughput() { + return throughput; + } + + public void setThroughput(@javax.annotation.Nullable Integer throughput) { + this.throughput = throughput; + } + + /** + * 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 PerformanceClass instance itself + */ + public PerformanceClass 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; + } + PerformanceClass performanceClass = (PerformanceClass) o; + return Objects.equals(this.iops, performanceClass.iops) + && Objects.equals(this.name, performanceClass.name) + && Objects.equals(this.throughput, performanceClass.throughput) + && Objects.equals(this.additionalProperties, performanceClass.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(iops, name, throughput, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PerformanceClass {\n"); + sb.append(" iops: ").append(toIndentedString(iops)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" throughput: ").append(toIndentedString(throughput)).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("iops", "name", "throughput")); + + // 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 PerformanceClass + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PerformanceClass.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PerformanceClass is not found in the empty JSON string", + PerformanceClass.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PerformanceClass.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PerformanceClass' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(PerformanceClass.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, PerformanceClass 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 PerformanceClass read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + PerformanceClass instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of PerformanceClass given an JSON string + * + * @param jsonString JSON string + * @return An instance of PerformanceClass + * @throws IOException if the JSON string is invalid with respect to PerformanceClass + */ + public static PerformanceClass fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PerformanceClass.class); + } + + /** + * Convert an instance of PerformanceClass to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePool.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePool.java new file mode 100644 index 0000000..6b6650c --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePool.java @@ -0,0 +1,764 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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.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; + +/** ResourcePool */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ResourcePool { + public static final String SERIALIZED_NAME_AVAILABILITY_ZONE = "availabilityZone"; + + @SerializedName(SERIALIZED_NAME_AVAILABILITY_ZONE) + @javax.annotation.Nullable private String availabilityZone; + + public static final String SERIALIZED_NAME_COUNT_SHARES = "countShares"; + + @SerializedName(SERIALIZED_NAME_COUNT_SHARES) + @javax.annotation.Nullable private Integer countShares; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable private String id; + + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_MOUNT_PATH = "mountPath"; + + @SerializedName(SERIALIZED_NAME_MOUNT_PATH) + @javax.annotation.Nullable private String mountPath; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PERFORMANCE_CLASS = "performanceClass"; + + @SerializedName(SERIALIZED_NAME_PERFORMANCE_CLASS) + @javax.annotation.Nullable private ResourcePoolPerformanceClass performanceClass; + + public static final String SERIALIZED_NAME_PERFORMANCE_CLASS_DOWNGRADABLE_AT = + "performanceClassDowngradableAt"; + + @SerializedName(SERIALIZED_NAME_PERFORMANCE_CLASS_DOWNGRADABLE_AT) + @javax.annotation.Nullable private OffsetDateTime performanceClassDowngradableAt; + + public static final String SERIALIZED_NAME_SIZE_REDUCIBLE_AT = "sizeReducibleAt"; + + @SerializedName(SERIALIZED_NAME_SIZE_REDUCIBLE_AT) + @javax.annotation.Nullable private OffsetDateTime sizeReducibleAt; + + public static final String SERIALIZED_NAME_SNAPSHOT_SCHEDULE = "snapshotSchedule"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_SCHEDULE) + @javax.annotation.Nullable private SnapshotSchedule snapshotSchedule; + + public static final String SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE = "snapshotsAreVisible"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE) + @javax.annotation.Nullable private Boolean snapshotsAreVisible; + + public static final String SERIALIZED_NAME_SPACE = "space"; + + @SerializedName(SERIALIZED_NAME_SPACE) + @javax.annotation.Nullable private ResourcePoolSpace space; + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nullable private String state; + + public ResourcePool() {} + + public ResourcePool availabilityZone(@javax.annotation.Nullable String availabilityZone) { + this.availabilityZone = availabilityZone; + return this; + } + + /** + * Name of the respective availability zone + * + * @return availabilityZone + */ + @javax.annotation.Nullable public String getAvailabilityZone() { + return availabilityZone; + } + + public void setAvailabilityZone(@javax.annotation.Nullable String availabilityZone) { + this.availabilityZone = availabilityZone; + } + + public ResourcePool countShares(@javax.annotation.Nullable Integer countShares) { + this.countShares = countShares; + return this; + } + + /** + * Number of Shares in the Resource Pool + * + * @return countShares + */ + @javax.annotation.Nullable public Integer getCountShares() { + return countShares; + } + + public void setCountShares(@javax.annotation.Nullable Integer countShares) { + this.countShares = countShares; + } + + public ResourcePool createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ResourcePool id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the Resource Pool + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public ResourcePool ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public ResourcePool addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * List of IPs that can mount the Resource Pool in read-only; IPs must have a subnet mask (e.g. + * \"172.16.0.0/24\" for a range of IPs, or \"172.16.0.250/32\" for a + * specific IP) + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public ResourcePool labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public ResourcePool putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Get labels + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public ResourcePool mountPath(@javax.annotation.Nullable String mountPath) { + this.mountPath = mountPath; + return this; + } + + /** + * Mount path of the Resource Pool, used to mount the Resource Pool Note that a Resource Pool + * can only be mounted in read-only + * + * @return mountPath + */ + @javax.annotation.Nullable public String getMountPath() { + return mountPath; + } + + public void setMountPath(@javax.annotation.Nullable String mountPath) { + this.mountPath = mountPath; + } + + public ResourcePool name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Resource Pool + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public ResourcePool performanceClass( + @javax.annotation.Nullable ResourcePoolPerformanceClass performanceClass) { + this.performanceClass = performanceClass; + return this; + } + + /** + * Information about the performance class + * + * @return performanceClass + */ + @javax.annotation.Nullable public ResourcePoolPerformanceClass getPerformanceClass() { + return performanceClass; + } + + public void setPerformanceClass( + @javax.annotation.Nullable ResourcePoolPerformanceClass performanceClass) { + this.performanceClass = performanceClass; + } + + public ResourcePool performanceClassDowngradableAt( + @javax.annotation.Nullable OffsetDateTime performanceClassDowngradableAt) { + this.performanceClassDowngradableAt = performanceClassDowngradableAt; + return this; + } + + /** + * Time when the performance class can be downgraded again. + * + * @return performanceClassDowngradableAt + */ + @javax.annotation.Nullable public OffsetDateTime getPerformanceClassDowngradableAt() { + return performanceClassDowngradableAt; + } + + public void setPerformanceClassDowngradableAt( + @javax.annotation.Nullable OffsetDateTime performanceClassDowngradableAt) { + this.performanceClassDowngradableAt = performanceClassDowngradableAt; + } + + public ResourcePool sizeReducibleAt(@javax.annotation.Nullable OffsetDateTime sizeReducibleAt) { + this.sizeReducibleAt = sizeReducibleAt; + return this; + } + + /** + * Time when the size can be reduced again. + * + * @return sizeReducibleAt + */ + @javax.annotation.Nullable public OffsetDateTime getSizeReducibleAt() { + return sizeReducibleAt; + } + + public void setSizeReducibleAt(@javax.annotation.Nullable OffsetDateTime sizeReducibleAt) { + this.sizeReducibleAt = sizeReducibleAt; + } + + public ResourcePool snapshotSchedule( + @javax.annotation.Nullable SnapshotSchedule snapshotSchedule) { + this.snapshotSchedule = snapshotSchedule; + return this; + } + + /** + * Get snapshotSchedule + * + * @return snapshotSchedule + */ + @javax.annotation.Nullable public SnapshotSchedule getSnapshotSchedule() { + return snapshotSchedule; + } + + public void setSnapshotSchedule(@javax.annotation.Nullable SnapshotSchedule snapshotSchedule) { + this.snapshotSchedule = snapshotSchedule; + } + + public ResourcePool snapshotsAreVisible( + @javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + return this; + } + + /** + * Whether the .snapshot directory is visible when mounting the resource pool. Setting this + * value to false might prevent you from accessing the snapshots (e.g. for security reasons). + * Additionally, the access to the snapshots is always controlled by the export policy of the + * resource pool. That means, if snapshots are visible and the export policy allows for reading + * the resource pool, then it also allows reading the snapshot of all shares. + * + * @return snapshotsAreVisible + */ + @javax.annotation.Nullable public Boolean getSnapshotsAreVisible() { + return snapshotsAreVisible; + } + + public void setSnapshotsAreVisible(@javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + } + + public ResourcePool space(@javax.annotation.Nullable ResourcePoolSpace space) { + this.space = space; + return this; + } + + /** + * Space information + * + * @return space + */ + @javax.annotation.Nullable public ResourcePoolSpace getSpace() { + return space; + } + + public void setSpace(@javax.annotation.Nullable ResourcePoolSpace space) { + this.space = space; + } + + public ResourcePool state(@javax.annotation.Nullable String state) { + this.state = state; + return this; + } + + /** + * State of the Resource Pool (possible values: [\"pending\", \"creating\", + * \"created\", \"updating\", \"error\", \"deleting\"]) + * + * @return state + */ + @javax.annotation.Nullable public String getState() { + return state; + } + + public void setState(@javax.annotation.Nullable String state) { + this.state = state; + } + + /** + * 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 ResourcePool instance itself + */ + public ResourcePool 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; + } + ResourcePool resourcePool = (ResourcePool) o; + return Objects.equals(this.availabilityZone, resourcePool.availabilityZone) + && Objects.equals(this.countShares, resourcePool.countShares) + && Objects.equals(this.createdAt, resourcePool.createdAt) + && Objects.equals(this.id, resourcePool.id) + && Objects.equals(this.ipAcl, resourcePool.ipAcl) + && Objects.equals(this.labels, resourcePool.labels) + && Objects.equals(this.mountPath, resourcePool.mountPath) + && Objects.equals(this.name, resourcePool.name) + && Objects.equals(this.performanceClass, resourcePool.performanceClass) + && Objects.equals( + this.performanceClassDowngradableAt, + resourcePool.performanceClassDowngradableAt) + && Objects.equals(this.sizeReducibleAt, resourcePool.sizeReducibleAt) + && Objects.equals(this.snapshotSchedule, resourcePool.snapshotSchedule) + && Objects.equals(this.snapshotsAreVisible, resourcePool.snapshotsAreVisible) + && Objects.equals(this.space, resourcePool.space) + && Objects.equals(this.state, resourcePool.state) + && Objects.equals(this.additionalProperties, resourcePool.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + availabilityZone, + countShares, + createdAt, + id, + ipAcl, + labels, + mountPath, + name, + performanceClass, + performanceClassDowngradableAt, + sizeReducibleAt, + snapshotSchedule, + snapshotsAreVisible, + space, + state, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourcePool {\n"); + sb.append(" availabilityZone: ").append(toIndentedString(availabilityZone)).append("\n"); + sb.append(" countShares: ").append(toIndentedString(countShares)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" mountPath: ").append(toIndentedString(mountPath)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" performanceClass: ").append(toIndentedString(performanceClass)).append("\n"); + sb.append(" performanceClassDowngradableAt: ") + .append(toIndentedString(performanceClassDowngradableAt)) + .append("\n"); + sb.append(" sizeReducibleAt: ").append(toIndentedString(sizeReducibleAt)).append("\n"); + sb.append(" snapshotSchedule: ").append(toIndentedString(snapshotSchedule)).append("\n"); + sb.append(" snapshotsAreVisible: ") + .append(toIndentedString(snapshotsAreVisible)) + .append("\n"); + sb.append(" space: ").append(toIndentedString(space)).append("\n"); + sb.append(" state: ").append(toIndentedString(state)).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( + "availabilityZone", + "countShares", + "createdAt", + "id", + "ipAcl", + "labels", + "mountPath", + "name", + "performanceClass", + "performanceClassDowngradableAt", + "sizeReducibleAt", + "snapshotSchedule", + "snapshotsAreVisible", + "space", + "state")); + + // 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 ResourcePool + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ResourcePool.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ResourcePool is not found in the empty JSON string", + ResourcePool.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("availabilityZone") != null + && !jsonObj.get("availabilityZone").isJsonNull()) + && !jsonObj.get("availabilityZone").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `availabilityZone` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("availabilityZone").toString())); + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + if ((jsonObj.get("mountPath") != null && !jsonObj.get("mountPath").isJsonNull()) + && !jsonObj.get("mountPath").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `mountPath` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("mountPath").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + // validate the optional field `performanceClass` + if (jsonObj.get("performanceClass") != null + && !jsonObj.get("performanceClass").isJsonNull()) { + ResourcePoolPerformanceClass.validateJsonElement(jsonObj.get("performanceClass")); + } + // validate the optional field `snapshotSchedule` + if (jsonObj.get("snapshotSchedule") != null + && !jsonObj.get("snapshotSchedule").isJsonNull()) { + SnapshotSchedule.validateJsonElement(jsonObj.get("snapshotSchedule")); + } + // validate the optional field `space` + if (jsonObj.get("space") != null && !jsonObj.get("space").isJsonNull()) { + ResourcePoolSpace.validateJsonElement(jsonObj.get("space")); + } + if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) + && !jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResourcePool.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResourcePool' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ResourcePool.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ResourcePool 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 ResourcePool read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResourcePool instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ResourcePool given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourcePool + * @throws IOException if the JSON string is invalid with respect to ResourcePool + */ + public static ResourcePool fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResourcePool.class); + } + + /** + * Convert an instance of ResourcePool to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolPerformanceClass.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolPerformanceClass.java new file mode 100644 index 0000000..8bc8c1a --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolPerformanceClass.java @@ -0,0 +1,349 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ResourcePoolPerformanceClass */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ResourcePoolPerformanceClass { + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PEAK_IOPS = "peakIops"; + + @SerializedName(SERIALIZED_NAME_PEAK_IOPS) + @javax.annotation.Nullable private Integer peakIops; + + public static final String SERIALIZED_NAME_THROUGHPUT = "throughput"; + + @SerializedName(SERIALIZED_NAME_THROUGHPUT) + @javax.annotation.Nullable private Integer throughput; + + public ResourcePoolPerformanceClass() {} + + public ResourcePoolPerformanceClass name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the performance class + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public ResourcePoolPerformanceClass peakIops(@javax.annotation.Nullable Integer peakIops) { + this.peakIops = peakIops; + return this; + } + + /** + * Max. IOPS of the Resource Pool. This is shared between every Share in the Resource Pool. + * + * @return peakIops + */ + @javax.annotation.Nullable public Integer getPeakIops() { + return peakIops; + } + + public void setPeakIops(@javax.annotation.Nullable Integer peakIops) { + this.peakIops = peakIops; + } + + public ResourcePoolPerformanceClass throughput(@javax.annotation.Nullable Integer throughput) { + this.throughput = throughput; + return this; + } + + /** + * Throughput of the Resource Pool. + * + * @return throughput + */ + @javax.annotation.Nullable public Integer getThroughput() { + return throughput; + } + + public void setThroughput(@javax.annotation.Nullable Integer throughput) { + this.throughput = throughput; + } + + /** + * 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 ResourcePoolPerformanceClass instance itself + */ + public ResourcePoolPerformanceClass 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; + } + ResourcePoolPerformanceClass resourcePoolPerformanceClass = + (ResourcePoolPerformanceClass) o; + return Objects.equals(this.name, resourcePoolPerformanceClass.name) + && Objects.equals(this.peakIops, resourcePoolPerformanceClass.peakIops) + && Objects.equals(this.throughput, resourcePoolPerformanceClass.throughput) + && Objects.equals( + this.additionalProperties, + resourcePoolPerformanceClass.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(name, peakIops, throughput, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourcePoolPerformanceClass {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" peakIops: ").append(toIndentedString(peakIops)).append("\n"); + sb.append(" throughput: ").append(toIndentedString(throughput)).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("name", "peakIops", "throughput")); + + // 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 + * ResourcePoolPerformanceClass + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ResourcePoolPerformanceClass.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ResourcePoolPerformanceClass is not found in the empty JSON string", + ResourcePoolPerformanceClass.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResourcePoolPerformanceClass.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResourcePoolPerformanceClass' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(ResourcePoolPerformanceClass.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ResourcePoolPerformanceClass 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 ResourcePoolPerformanceClass read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResourcePoolPerformanceClass instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ResourcePoolPerformanceClass given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourcePoolPerformanceClass + * @throws IOException if the JSON string is invalid with respect to + * ResourcePoolPerformanceClass + */ + public static ResourcePoolPerformanceClass fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResourcePoolPerformanceClass.class); + } + + /** + * Convert an instance of ResourcePoolPerformanceClass to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSnapshot.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSnapshot.java new file mode 100644 index 0000000..380c89a --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSnapshot.java @@ -0,0 +1,470 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** ResourcePoolSnapshot */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ResourcePoolSnapshot { + public static final String SERIALIZED_NAME_COMMENT = "comment"; + + @SerializedName(SERIALIZED_NAME_COMMENT) + @javax.annotation.Nullable private String comment; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_LOGICAL_SIZE_GIGABYTES = "logicalSizeGigabytes"; + + @SerializedName(SERIALIZED_NAME_LOGICAL_SIZE_GIGABYTES) + @javax.annotation.Nullable private Integer logicalSizeGigabytes; + + public static final String SERIALIZED_NAME_RESOURCE_POOL_ID = "resourcePoolId"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL_ID) + @javax.annotation.Nullable private String resourcePoolId; + + public static final String SERIALIZED_NAME_SIZE_GIGABYTES = "sizeGigabytes"; + + @SerializedName(SERIALIZED_NAME_SIZE_GIGABYTES) + @javax.annotation.Nullable private Integer sizeGigabytes; + + public static final String SERIALIZED_NAME_SNAPSHOT_NAME = "snapshotName"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_NAME) + @javax.annotation.Nullable private String snapshotName; + + public ResourcePoolSnapshot() {} + + public ResourcePoolSnapshot comment(@javax.annotation.Nullable String comment) { + this.comment = comment; + return this; + } + + /** + * (optional) A comment to add more information about a snapshot + * + * @return comment + */ + @javax.annotation.Nullable public String getComment() { + return comment; + } + + public void setComment(@javax.annotation.Nullable String comment) { + this.comment = comment; + } + + public ResourcePoolSnapshot createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ResourcePoolSnapshot logicalSizeGigabytes( + @javax.annotation.Nullable Integer logicalSizeGigabytes) { + this.logicalSizeGigabytes = logicalSizeGigabytes; + return this; + } + + /** + * Represents the user-visible data size at the time of the snapshot in Gibibytes (e.g. what’s + * in the snapshot) + * + * @return logicalSizeGigabytes + */ + @javax.annotation.Nullable public Integer getLogicalSizeGigabytes() { + return logicalSizeGigabytes; + } + + public void setLogicalSizeGigabytes(@javax.annotation.Nullable Integer logicalSizeGigabytes) { + this.logicalSizeGigabytes = logicalSizeGigabytes; + } + + public ResourcePoolSnapshot resourcePoolId(@javax.annotation.Nullable String resourcePoolId) { + this.resourcePoolId = resourcePoolId; + return this; + } + + /** + * ID of the Resource Pool of the Snapshot + * + * @return resourcePoolId + */ + @javax.annotation.Nullable public String getResourcePoolId() { + return resourcePoolId; + } + + public void setResourcePoolId(@javax.annotation.Nullable String resourcePoolId) { + this.resourcePoolId = resourcePoolId; + } + + public ResourcePoolSnapshot sizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + return this; + } + + /** + * Reflects the actual storage footprint in the backend at snapshot time in Gibibytes (e.g. how + * much storage from the Resource Pool does it use). + * + * @return sizeGigabytes + */ + @javax.annotation.Nullable public Integer getSizeGigabytes() { + return sizeGigabytes; + } + + public void setSizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + } + + public ResourcePoolSnapshot snapshotName(@javax.annotation.Nullable String snapshotName) { + this.snapshotName = snapshotName; + return this; + } + + /** + * Name of the Resource Pool Snapshot + * + * @return snapshotName + */ + @javax.annotation.Nullable public String getSnapshotName() { + return snapshotName; + } + + public void setSnapshotName(@javax.annotation.Nullable String snapshotName) { + this.snapshotName = snapshotName; + } + + /** + * 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 ResourcePoolSnapshot instance itself + */ + public ResourcePoolSnapshot 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; + } + ResourcePoolSnapshot resourcePoolSnapshot = (ResourcePoolSnapshot) o; + return Objects.equals(this.comment, resourcePoolSnapshot.comment) + && Objects.equals(this.createdAt, resourcePoolSnapshot.createdAt) + && Objects.equals( + this.logicalSizeGigabytes, resourcePoolSnapshot.logicalSizeGigabytes) + && Objects.equals(this.resourcePoolId, resourcePoolSnapshot.resourcePoolId) + && Objects.equals(this.sizeGigabytes, resourcePoolSnapshot.sizeGigabytes) + && Objects.equals(this.snapshotName, resourcePoolSnapshot.snapshotName) + && Objects.equals( + this.additionalProperties, resourcePoolSnapshot.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + comment, + createdAt, + logicalSizeGigabytes, + resourcePoolId, + sizeGigabytes, + snapshotName, + additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourcePoolSnapshot {\n"); + sb.append(" comment: ").append(toIndentedString(comment)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" logicalSizeGigabytes: ") + .append(toIndentedString(logicalSizeGigabytes)) + .append("\n"); + sb.append(" resourcePoolId: ").append(toIndentedString(resourcePoolId)).append("\n"); + sb.append(" sizeGigabytes: ").append(toIndentedString(sizeGigabytes)).append("\n"); + sb.append(" snapshotName: ").append(toIndentedString(snapshotName)).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( + "comment", + "createdAt", + "logicalSizeGigabytes", + "resourcePoolId", + "sizeGigabytes", + "snapshotName")); + + // 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 ResourcePoolSnapshot + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ResourcePoolSnapshot.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ResourcePoolSnapshot is not found in the empty JSON string", + ResourcePoolSnapshot.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("comment") != null && !jsonObj.get("comment").isJsonNull()) + && !jsonObj.get("comment").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `comment` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("comment").toString())); + } + if ((jsonObj.get("resourcePoolId") != null && !jsonObj.get("resourcePoolId").isJsonNull()) + && !jsonObj.get("resourcePoolId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `resourcePoolId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("resourcePoolId").toString())); + } + if ((jsonObj.get("snapshotName") != null && !jsonObj.get("snapshotName").isJsonNull()) + && !jsonObj.get("snapshotName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `snapshotName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("snapshotName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResourcePoolSnapshot.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResourcePoolSnapshot' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ResourcePoolSnapshot.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ResourcePoolSnapshot 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 ResourcePoolSnapshot read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResourcePoolSnapshot instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ResourcePoolSnapshot given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourcePoolSnapshot + * @throws IOException if the JSON string is invalid with respect to ResourcePoolSnapshot + */ + public static ResourcePoolSnapshot fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResourcePoolSnapshot.class); + } + + /** + * Convert an instance of ResourcePoolSnapshot to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSpace.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSpace.java new file mode 100644 index 0000000..902c474 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ResourcePoolSpace.java @@ -0,0 +1,358 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** ResourcePoolSpace */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ResourcePoolSpace { + public static final String SERIALIZED_NAME_AVAILABLE_GIGABYTES = "availableGigabytes"; + + @SerializedName(SERIALIZED_NAME_AVAILABLE_GIGABYTES) + @javax.annotation.Nullable private Double availableGigabytes; + + public static final String SERIALIZED_NAME_SIZE_GIGABYTES = "sizeGigabytes"; + + @SerializedName(SERIALIZED_NAME_SIZE_GIGABYTES) + @javax.annotation.Nullable private Integer sizeGigabytes; + + public static final String SERIALIZED_NAME_USED_GIGABYTES = "usedGigabytes"; + + @SerializedName(SERIALIZED_NAME_USED_GIGABYTES) + @javax.annotation.Nullable private Double usedGigabytes; + + public ResourcePoolSpace() {} + + public ResourcePoolSpace availableGigabytes( + @javax.annotation.Nullable Double availableGigabytes) { + this.availableGigabytes = availableGigabytes; + return this; + } + + /** + * Available space of the Resource Pool (only available when retrieving a single Resource Pool + * by ID) + * + * @return availableGigabytes + */ + @javax.annotation.Nullable public Double getAvailableGigabytes() { + return availableGigabytes; + } + + public void setAvailableGigabytes(@javax.annotation.Nullable Double availableGigabytes) { + this.availableGigabytes = availableGigabytes; + } + + public ResourcePoolSpace sizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + return this; + } + + /** + * Size of the Resource Pool in Gibibytes. + * + * @return sizeGigabytes + */ + @javax.annotation.Nullable public Integer getSizeGigabytes() { + return sizeGigabytes; + } + + public void setSizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + } + + public ResourcePoolSpace usedGigabytes(@javax.annotation.Nullable Double usedGigabytes) { + this.usedGigabytes = usedGigabytes; + return this; + } + + /** + * Used space of the Resource Pool (only available when retrieving a single Resource Pool by ID) + * + * @return usedGigabytes + */ + @javax.annotation.Nullable public Double getUsedGigabytes() { + return usedGigabytes; + } + + public void setUsedGigabytes(@javax.annotation.Nullable Double usedGigabytes) { + this.usedGigabytes = usedGigabytes; + } + + /** + * 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 ResourcePoolSpace instance itself + */ + public ResourcePoolSpace 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; + } + ResourcePoolSpace resourcePoolSpace = (ResourcePoolSpace) o; + return Objects.equals(this.availableGigabytes, resourcePoolSpace.availableGigabytes) + && Objects.equals(this.sizeGigabytes, resourcePoolSpace.sizeGigabytes) + && Objects.equals(this.usedGigabytes, resourcePoolSpace.usedGigabytes) + && Objects.equals( + this.additionalProperties, resourcePoolSpace.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(availableGigabytes, sizeGigabytes, usedGigabytes, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ResourcePoolSpace {\n"); + sb.append(" availableGigabytes: ") + .append(toIndentedString(availableGigabytes)) + .append("\n"); + sb.append(" sizeGigabytes: ").append(toIndentedString(sizeGigabytes)).append("\n"); + sb.append(" usedGigabytes: ").append(toIndentedString(usedGigabytes)).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("availableGigabytes", "sizeGigabytes", "usedGigabytes")); + + // 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 ResourcePoolSpace + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ResourcePoolSpace.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ResourcePoolSpace is not found in the empty JSON string", + ResourcePoolSpace.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ResourcePoolSpace.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ResourcePoolSpace' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ResourcePoolSpace.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ResourcePoolSpace 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 ResourcePoolSpace read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ResourcePoolSpace instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ResourcePoolSpace given an JSON string + * + * @param jsonString JSON string + * @return An instance of ResourcePoolSpace + * @throws IOException if the JSON string is invalid with respect to ResourcePoolSpace + */ + public static ResourcePoolSpace fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ResourcePoolSpace.class); + } + + /** + * Convert an instance of ResourcePoolSpace to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Share.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Share.java new file mode 100644 index 0000000..26e4b53 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Share.java @@ -0,0 +1,546 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** Share */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Share { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_EXPORT_POLICY = "exportPolicy"; + + @SerializedName(SERIALIZED_NAME_EXPORT_POLICY) + @javax.annotation.Nullable private ShareExportPolicy exportPolicy; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable private String id; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_MOUNT_PATH = "mountPath"; + + @SerializedName(SERIALIZED_NAME_MOUNT_PATH) + @javax.annotation.Nullable private String mountPath; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES = + "spaceHardLimitGigabytes"; + + @SerializedName(SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES) + @javax.annotation.Nullable private Integer spaceHardLimitGigabytes; + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nullable private String state; + + public Share() {} + + public Share createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public Share exportPolicy(@javax.annotation.Nullable ShareExportPolicy exportPolicy) { + this.exportPolicy = exportPolicy; + return this; + } + + /** + * Details of the Share Export Policy to use in the Share. Note that if this is not set, the + * Share can only be mounted in read only by clients with IPs matching the IP ACL of the + * Resource Pool hosting this Share + * + * @return exportPolicy + */ + @javax.annotation.Nullable public ShareExportPolicy getExportPolicy() { + return exportPolicy; + } + + public void setExportPolicy(@javax.annotation.Nullable ShareExportPolicy exportPolicy) { + this.exportPolicy = exportPolicy; + } + + public Share id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the Share + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public Share labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public Share putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share keys are validated + * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty + * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public Share mountPath(@javax.annotation.Nullable String mountPath) { + this.mountPath = mountPath; + return this; + } + + /** + * Mount path of the Share, used to mount the Share + * + * @return mountPath + */ + @javax.annotation.Nullable public String getMountPath() { + return mountPath; + } + + public void setMountPath(@javax.annotation.Nullable String mountPath) { + this.mountPath = mountPath; + } + + public Share name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Share + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public Share spaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + return this; + } + + /** + * Space hard limit for the Share. If zero, the Share will have access to the full space of the + * Resource Pool it lives in. (unit: gibibytes) + * + * @return spaceHardLimitGigabytes + */ + @javax.annotation.Nullable public Integer getSpaceHardLimitGigabytes() { + return spaceHardLimitGigabytes; + } + + public void setSpaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + } + + public Share state(@javax.annotation.Nullable String state) { + this.state = state; + return this; + } + + /** + * State of the Resource Pool Snapshot (possible values: [\"pending\", + * \"creating\", \"created\", \"error\", \"deleting\"]) + * + * @return state + */ + @javax.annotation.Nullable public String getState() { + return state; + } + + public void setState(@javax.annotation.Nullable String state) { + this.state = state; + } + + /** + * 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 Share instance itself + */ + public Share 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; + } + Share share = (Share) o; + return Objects.equals(this.createdAt, share.createdAt) + && Objects.equals(this.exportPolicy, share.exportPolicy) + && Objects.equals(this.id, share.id) + && Objects.equals(this.labels, share.labels) + && Objects.equals(this.mountPath, share.mountPath) + && Objects.equals(this.name, share.name) + && Objects.equals(this.spaceHardLimitGigabytes, share.spaceHardLimitGigabytes) + && Objects.equals(this.state, share.state) + && Objects.equals(this.additionalProperties, share.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + exportPolicy, + id, + labels, + mountPath, + name, + spaceHardLimitGigabytes, + state, + additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Share {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" exportPolicy: ").append(toIndentedString(exportPolicy)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" mountPath: ").append(toIndentedString(mountPath)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" spaceHardLimitGigabytes: ") + .append(toIndentedString(spaceHardLimitGigabytes)) + .append("\n"); + sb.append(" state: ").append(toIndentedString(state)).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( + "createdAt", + "exportPolicy", + "id", + "labels", + "mountPath", + "name", + "spaceHardLimitGigabytes", + "state")); + + // 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 Share + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Share.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Share is not found in the empty JSON string", + Share.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `exportPolicy` + if (jsonObj.get("exportPolicy") != null && !jsonObj.get("exportPolicy").isJsonNull()) { + ShareExportPolicy.validateJsonElement(jsonObj.get("exportPolicy")); + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("mountPath") != null && !jsonObj.get("mountPath").isJsonNull()) + && !jsonObj.get("mountPath").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `mountPath` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("mountPath").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) + && !jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Share.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Share' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Share.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Share 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 Share read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Share instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of Share given an JSON string + * + * @param jsonString JSON string + * @return An instance of Share + * @throws IOException if the JSON string is invalid with respect to Share + */ + public static Share fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Share.class); + } + + /** + * Convert an instance of Share to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicy.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicy.java new file mode 100644 index 0000000..a29a519 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicy.java @@ -0,0 +1,480 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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.time.OffsetDateTime; +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; + +/** ShareExportPolicy */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ShareExportPolicy { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable private String id; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_RULES = "rules"; + + @SerializedName(SERIALIZED_NAME_RULES) + @javax.annotation.Nullable private List rules = new ArrayList<>(); + + public static final String SERIALIZED_NAME_SHARES_USING_EXPORT_POLICY = + "sharesUsingExportPolicy"; + + @SerializedName(SERIALIZED_NAME_SHARES_USING_EXPORT_POLICY) + @javax.annotation.Nullable private Integer sharesUsingExportPolicy; + + public ShareExportPolicy() {} + + public ShareExportPolicy createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ShareExportPolicy id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the Share Export Policy + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public ShareExportPolicy labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public ShareExportPolicy putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share export policy keys + * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and + * cannot be empty values are validated using the following regex + * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public ShareExportPolicy name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Share Export Policy + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public ShareExportPolicy rules(@javax.annotation.Nullable List rules) { + this.rules = rules; + return this; + } + + public ShareExportPolicy addRulesItem(ShareExportPolicyRule rulesItem) { + if (this.rules == null) { + this.rules = new ArrayList<>(); + } + this.rules.add(rulesItem); + return this; + } + + /** + * List of rules of the Share Export Policy. The order of the rules within the array does not + * matter - what matters is the field \"order\" within each rule + * + * @return rules + */ + @javax.annotation.Nullable public List getRules() { + return rules; + } + + public void setRules(@javax.annotation.Nullable List rules) { + this.rules = rules; + } + + public ShareExportPolicy sharesUsingExportPolicy( + @javax.annotation.Nullable Integer sharesUsingExportPolicy) { + this.sharesUsingExportPolicy = sharesUsingExportPolicy; + return this; + } + + /** + * Number of Shares using this Share Export Policy + * + * @return sharesUsingExportPolicy + */ + @javax.annotation.Nullable public Integer getSharesUsingExportPolicy() { + return sharesUsingExportPolicy; + } + + public void setSharesUsingExportPolicy( + @javax.annotation.Nullable Integer sharesUsingExportPolicy) { + this.sharesUsingExportPolicy = sharesUsingExportPolicy; + } + + /** + * 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 ShareExportPolicy instance itself + */ + public ShareExportPolicy 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; + } + ShareExportPolicy shareExportPolicy = (ShareExportPolicy) o; + return Objects.equals(this.createdAt, shareExportPolicy.createdAt) + && Objects.equals(this.id, shareExportPolicy.id) + && Objects.equals(this.labels, shareExportPolicy.labels) + && Objects.equals(this.name, shareExportPolicy.name) + && Objects.equals(this.rules, shareExportPolicy.rules) + && Objects.equals( + this.sharesUsingExportPolicy, shareExportPolicy.sharesUsingExportPolicy) + && Objects.equals( + this.additionalProperties, shareExportPolicy.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, id, labels, name, rules, sharesUsingExportPolicy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShareExportPolicy {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).append("\n"); + sb.append(" sharesUsingExportPolicy: ") + .append(toIndentedString(sharesUsingExportPolicy)) + .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( + "createdAt", + "id", + "labels", + "name", + "rules", + "sharesUsingExportPolicy")); + + // 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 ShareExportPolicy + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ShareExportPolicy.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ShareExportPolicy is not found in the empty JSON string", + ShareExportPolicy.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "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( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (jsonObj.get("rules") != null && !jsonObj.get("rules").isJsonNull()) { + JsonArray jsonArrayrules = jsonObj.getAsJsonArray("rules"); + if (jsonArrayrules != null) { + // ensure the json data is an array + if (!jsonObj.get("rules").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `rules` to be an array in the JSON string but got `%s`", + jsonObj.get("rules").toString())); + } + + // validate the optional field `rules` (array) + for (int i = 0; i < jsonArrayrules.size(); i++) { + ShareExportPolicyRule.validateJsonElement(jsonArrayrules.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ShareExportPolicy.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ShareExportPolicy' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ShareExportPolicy.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ShareExportPolicy 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 ShareExportPolicy read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ShareExportPolicy instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ShareExportPolicy given an JSON string + * + * @param jsonString JSON string + * @return An instance of ShareExportPolicy + * @throws IOException if the JSON string is invalid with respect to ShareExportPolicy + */ + public static ShareExportPolicy fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ShareExportPolicy.class); + } + + /** + * Convert an instance of ShareExportPolicy to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicyRule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicyRule.java new file mode 100644 index 0000000..00ab1e9 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ShareExportPolicyRule.java @@ -0,0 +1,533 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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.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 org.openapitools.jackson.nullable.JsonNullable; + +/** ShareExportPolicyRule */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ShareExportPolicyRule { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nullable private OffsetDateTime createdAt; + + 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.Nullable private String id; + + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ORDER = "order"; + + @SerializedName(SERIALIZED_NAME_ORDER) + @javax.annotation.Nullable private Integer order; + + public static final String SERIALIZED_NAME_READ_ONLY = "readOnly"; + + @SerializedName(SERIALIZED_NAME_READ_ONLY) + @javax.annotation.Nullable private Boolean readOnly; + + public static final String SERIALIZED_NAME_SET_UUID = "setUuid"; + + @SerializedName(SERIALIZED_NAME_SET_UUID) + @javax.annotation.Nullable private Boolean setUuid; + + public static final String SERIALIZED_NAME_SUPER_USER = "superUser"; + + @SerializedName(SERIALIZED_NAME_SUPER_USER) + @javax.annotation.Nullable private Boolean superUser; + + public ShareExportPolicyRule() {} + + public ShareExportPolicyRule createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public ShareExportPolicyRule description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Description of the Rule (optional) + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public ShareExportPolicyRule id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the Share Export Policy Rule + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public ShareExportPolicyRule ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public ShareExportPolicyRule addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * IP access control list, where IPs must have a subnet mask (e.g. \"172.16.0.0/24\" + * for a range of IPs, or \"172.16.0.251/32\" for a specific IP) This array cannot be + * empty + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public ShareExportPolicyRule order(@javax.annotation.Nullable Integer order) { + this.order = order; + return this; + } + + /** + * Order of the rule within a Share Export Policy. The order is used so that when a client IP + * matches multiple rules, the first rule is applied This field must be set + * + * @return order + */ + @javax.annotation.Nullable public Integer getOrder() { + return order; + } + + public void setOrder(@javax.annotation.Nullable Integer order) { + this.order = order; + } + + public ShareExportPolicyRule readOnly(@javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule can only mount the share in read only mode + * Default: false + * + * @return readOnly + */ + @javax.annotation.Nullable public Boolean getReadOnly() { + return readOnly; + } + + public void setReadOnly(@javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + } + + public ShareExportPolicyRule setUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + return this; + } + + /** + * Flag to honor set UUID Default: false + * + * @return setUuid + */ + @javax.annotation.Nullable public Boolean getSetUuid() { + return setUuid; + } + + public void setSetUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + } + + public ShareExportPolicyRule superUser(@javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule have root access on the Share Default: true + * + * @return superUser + */ + @javax.annotation.Nullable public Boolean getSuperUser() { + return superUser; + } + + public void setSuperUser(@javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + } + + /** + * 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 ShareExportPolicyRule instance itself + */ + public ShareExportPolicyRule 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; + } + ShareExportPolicyRule shareExportPolicyRule = (ShareExportPolicyRule) o; + return Objects.equals(this.createdAt, shareExportPolicyRule.createdAt) + && Objects.equals(this.description, shareExportPolicyRule.description) + && Objects.equals(this.id, shareExportPolicyRule.id) + && Objects.equals(this.ipAcl, shareExportPolicyRule.ipAcl) + && Objects.equals(this.order, shareExportPolicyRule.order) + && Objects.equals(this.readOnly, shareExportPolicyRule.readOnly) + && Objects.equals(this.setUuid, shareExportPolicyRule.setUuid) + && Objects.equals(this.superUser, shareExportPolicyRule.superUser) + && Objects.equals( + this.additionalProperties, shareExportPolicyRule.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + description, + id, + ipAcl, + order, + readOnly, + setUuid, + superUser, + additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ShareExportPolicyRule {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" order: ").append(toIndentedString(order)).append("\n"); + sb.append(" readOnly: ").append(toIndentedString(readOnly)).append("\n"); + sb.append(" setUuid: ").append(toIndentedString(setUuid)).append("\n"); + sb.append(" superUser: ").append(toIndentedString(superUser)).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( + "createdAt", + "description", + "id", + "ipAcl", + "order", + "readOnly", + "setUuid", + "superUser")); + + // 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 ShareExportPolicyRule + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ShareExportPolicyRule.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ShareExportPolicyRule is not found in the empty JSON string", + ShareExportPolicyRule.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ShareExportPolicyRule.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ShareExportPolicyRule' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ShareExportPolicyRule.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ShareExportPolicyRule 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 ShareExportPolicyRule read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ShareExportPolicyRule instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ShareExportPolicyRule given an JSON string + * + * @param jsonString JSON string + * @return An instance of ShareExportPolicyRule + * @throws IOException if the JSON string is invalid with respect to ShareExportPolicyRule + */ + public static ShareExportPolicyRule fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ShareExportPolicyRule.class); + } + + /** + * Convert an instance of ShareExportPolicyRule to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/SnapshotSchedule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/SnapshotSchedule.java new file mode 100644 index 0000000..6807045 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/SnapshotSchedule.java @@ -0,0 +1,323 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** SnapshotSchedule */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class SnapshotSchedule { + public static final String SERIALIZED_NAME_CRON = "cron"; + + @SerializedName(SERIALIZED_NAME_CRON) + @javax.annotation.Nullable private String cron; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public SnapshotSchedule() {} + + public SnapshotSchedule cron(@javax.annotation.Nullable String cron) { + this.cron = cron; + return this; + } + + /** + * Cron of the Snapshot Schedule (follows the cron schedule expression in Unix-like systems) + * + * @return cron + */ + @javax.annotation.Nullable public String getCron() { + return cron; + } + + public void setCron(@javax.annotation.Nullable String cron) { + this.cron = cron; + } + + public SnapshotSchedule name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the Snapshot Schedule + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SnapshotSchedule instance itself + */ + public SnapshotSchedule 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; + } + SnapshotSchedule snapshotSchedule = (SnapshotSchedule) o; + return Objects.equals(this.cron, snapshotSchedule.cron) + && Objects.equals(this.name, snapshotSchedule.name) + && Objects.equals(this.additionalProperties, snapshotSchedule.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(cron, name, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SnapshotSchedule {\n"); + sb.append(" cron: ").append(toIndentedString(cron)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).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("cron", "name")); + + // 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 SnapshotSchedule + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SnapshotSchedule.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in SnapshotSchedule is not found in the empty JSON string", + SnapshotSchedule.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("cron") != null && !jsonObj.get("cron").isJsonNull()) + && !jsonObj.get("cron").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `cron` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("cron").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SnapshotSchedule.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SnapshotSchedule' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(SnapshotSchedule.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, SnapshotSchedule 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 SnapshotSchedule read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SnapshotSchedule instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of SnapshotSchedule given an JSON string + * + * @param jsonString JSON string + * @return An instance of SnapshotSchedule + * @throws IOException if the JSON string is invalid with respect to SnapshotSchedule + */ + public static SnapshotSchedule fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SnapshotSchedule.class); + } + + /** + * Convert an instance of SnapshotSchedule to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Status.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Status.java new file mode 100644 index 0000000..de4a16e --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/Status.java @@ -0,0 +1,367 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** + * The `Status` type defines a logical error model that is suitable for different + * programming environments, including REST APIs and RPC APIs. It is used by + * [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: + * error code, error message, and error details. You can find out more about this error model and + * how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Status { + public static final String SERIALIZED_NAME_CODE = "code"; + + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nullable 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.Nullable private String message; + + public Status() {} + + public Status code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + * + * @return code + */ + @javax.annotation.Nullable public Integer getCode() { + return code; + } + + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + public Status details(@javax.annotation.Nullable List details) { + this.details = details; + return this; + } + + public Status addDetailsItem(GoogleProtobufAny detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * A list of messages that carry the error details. There is a common set of message types for + * APIs to use. + * + * @return details + */ + @javax.annotation.Nullable public List getDetails() { + return details; + } + + public void setDetails(@javax.annotation.Nullable List details) { + this.details = details; + } + + public Status message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * A developer-facing error message, which should be in English. Any user-facing error message + * should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] + * field, or localized by the client. + * + * @return message + */ + @javax.annotation.Nullable public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Status instance itself + */ + public Status putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Status status = (Status) o; + return Objects.equals(this.code, status.code) + && Objects.equals(this.details, status.details) + && Objects.equals(this.message, status.message) + && Objects.equals(this.additionalProperties, status.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(code, details, message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Status {\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(" 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")); + + // 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 Status + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Status.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Status is not found in the empty JSON string", + Status.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("details") != null + && !jsonObj.get("details").isJsonNull() + && !jsonObj.get("details").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `details` to be an array in the JSON string but got `%s`", + jsonObj.get("details").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) + && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `message` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Status.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Status' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Status.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Status value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : + value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty( + entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Status read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Status instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of Status given an JSON string + * + * @param jsonString JSON string + * @return An instance of Status + * @throws IOException if the JSON string is invalid with respect to Status + */ + public static Status fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Status.class); + } + + /** + * Convert an instance of Status to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolPayload.java new file mode 100644 index 0000000..e42c955 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolPayload.java @@ -0,0 +1,504 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** UpdateResourcePoolPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateResourcePoolPayload { + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_PERFORMANCE_CLASS = "performanceClass"; + + @SerializedName(SERIALIZED_NAME_PERFORMANCE_CLASS) + @javax.annotation.Nullable private String performanceClass; + + public static final String SERIALIZED_NAME_SIZE_GIGABYTES = "sizeGigabytes"; + + @SerializedName(SERIALIZED_NAME_SIZE_GIGABYTES) + @javax.annotation.Nullable private Integer sizeGigabytes; + + public static final String SERIALIZED_NAME_SNAPSHOT_SCHEDULE_NAME = "snapshotScheduleName"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOT_SCHEDULE_NAME) + @javax.annotation.Nullable private String snapshotScheduleName; + + public static final String SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE = "snapshotsAreVisible"; + + @SerializedName(SERIALIZED_NAME_SNAPSHOTS_ARE_VISIBLE) + @javax.annotation.Nullable private Boolean snapshotsAreVisible; + + public UpdateResourcePoolPayload() {} + + public UpdateResourcePoolPayload ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public UpdateResourcePoolPayload addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * (optional) List of IPs that can mount the Resource Pool in read-only; IPs must have a subnet + * mask (e.g. \"172.16.0.0/24\" for a range of IPs, or \"172.16.0.250/32\" + * for a specific IP) + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public UpdateResourcePoolPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public UpdateResourcePoolPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the resource pool keys are + * validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot + * be empty values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public UpdateResourcePoolPayload performanceClass( + @javax.annotation.Nullable String performanceClass) { + this.performanceClass = performanceClass; + return this; + } + + /** + * (optional) Name of the performance class + * + * @return performanceClass + */ + @javax.annotation.Nullable public String getPerformanceClass() { + return performanceClass; + } + + public void setPerformanceClass(@javax.annotation.Nullable String performanceClass) { + this.performanceClass = performanceClass; + } + + public UpdateResourcePoolPayload sizeGigabytes( + @javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + return this; + } + + /** + * (optional) Size of the Resource Pool (unit: gigabytes) + * + * @return sizeGigabytes + */ + @javax.annotation.Nullable public Integer getSizeGigabytes() { + return sizeGigabytes; + } + + public void setSizeGigabytes(@javax.annotation.Nullable Integer sizeGigabytes) { + this.sizeGigabytes = sizeGigabytes; + } + + public UpdateResourcePoolPayload snapshotScheduleName( + @javax.annotation.Nullable String snapshotScheduleName) { + this.snapshotScheduleName = snapshotScheduleName; + return this; + } + + /** + * (optional) Name of the Snapshot Schedule to use If not set, the Snapshot Schedule is not + * updated If set to an empty string, the Snapshot Schedule is removed + * + * @return snapshotScheduleName + */ + @javax.annotation.Nullable public String getSnapshotScheduleName() { + return snapshotScheduleName; + } + + public void setSnapshotScheduleName(@javax.annotation.Nullable String snapshotScheduleName) { + this.snapshotScheduleName = snapshotScheduleName; + } + + public UpdateResourcePoolPayload snapshotsAreVisible( + @javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + return this; + } + + /** + * Whether the .snapshot directory is visible when mounting the resource pool. Setting this + * value to false might prevent you from accessing the snapshots (e.g. for security reasons). + * Additionally, the access to the snapshots is always controlled by the export policy of the + * resource pool. That means, if snapshots are visible and the export policy allows for reading + * the resource pool, then it also allows reading the snapshot of all shares. + * + * @return snapshotsAreVisible + */ + @javax.annotation.Nullable public Boolean getSnapshotsAreVisible() { + return snapshotsAreVisible; + } + + public void setSnapshotsAreVisible(@javax.annotation.Nullable Boolean snapshotsAreVisible) { + this.snapshotsAreVisible = snapshotsAreVisible; + } + + /** + * 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 UpdateResourcePoolPayload instance itself + */ + public UpdateResourcePoolPayload 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; + } + UpdateResourcePoolPayload updateResourcePoolPayload = (UpdateResourcePoolPayload) o; + return Objects.equals(this.ipAcl, updateResourcePoolPayload.ipAcl) + && Objects.equals(this.labels, updateResourcePoolPayload.labels) + && Objects.equals(this.performanceClass, updateResourcePoolPayload.performanceClass) + && Objects.equals(this.sizeGigabytes, updateResourcePoolPayload.sizeGigabytes) + && Objects.equals( + this.snapshotScheduleName, updateResourcePoolPayload.snapshotScheduleName) + && Objects.equals( + this.snapshotsAreVisible, updateResourcePoolPayload.snapshotsAreVisible) + && Objects.equals( + this.additionalProperties, updateResourcePoolPayload.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + ipAcl, + labels, + performanceClass, + sizeGigabytes, + snapshotScheduleName, + snapshotsAreVisible, + additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateResourcePoolPayload {\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" performanceClass: ").append(toIndentedString(performanceClass)).append("\n"); + sb.append(" sizeGigabytes: ").append(toIndentedString(sizeGigabytes)).append("\n"); + sb.append(" snapshotScheduleName: ") + .append(toIndentedString(snapshotScheduleName)) + .append("\n"); + sb.append(" snapshotsAreVisible: ") + .append(toIndentedString(snapshotsAreVisible)) + .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( + "ipAcl", + "labels", + "performanceClass", + "sizeGigabytes", + "snapshotScheduleName", + "snapshotsAreVisible")); + + // 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 UpdateResourcePoolPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateResourcePoolPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateResourcePoolPayload is not found in the empty JSON string", + UpdateResourcePoolPayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + if ((jsonObj.get("performanceClass") != null + && !jsonObj.get("performanceClass").isJsonNull()) + && !jsonObj.get("performanceClass").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `performanceClass` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("performanceClass").toString())); + } + if ((jsonObj.get("snapshotScheduleName") != null + && !jsonObj.get("snapshotScheduleName").isJsonNull()) + && !jsonObj.get("snapshotScheduleName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `snapshotScheduleName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("snapshotScheduleName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateResourcePoolPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateResourcePoolPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateResourcePoolPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateResourcePoolPayload 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 UpdateResourcePoolPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateResourcePoolPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateResourcePoolPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateResourcePoolPayload + * @throws IOException if the JSON string is invalid with respect to UpdateResourcePoolPayload + */ + public static UpdateResourcePoolPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateResourcePoolPayload.class); + } + + /** + * Convert an instance of UpdateResourcePoolPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolResponse.java new file mode 100644 index 0000000..b642fed --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateResourcePoolResponse.java @@ -0,0 +1,291 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** UpdateResourcePoolResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateResourcePoolResponse { + public static final String SERIALIZED_NAME_RESOURCE_POOL = "resourcePool"; + + @SerializedName(SERIALIZED_NAME_RESOURCE_POOL) + @javax.annotation.Nullable private ResourcePool resourcePool; + + public UpdateResourcePoolResponse() {} + + public UpdateResourcePoolResponse resourcePool( + @javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + return this; + } + + /** + * Updated Resource Pool + * + * @return resourcePool + */ + @javax.annotation.Nullable public ResourcePool getResourcePool() { + return resourcePool; + } + + public void setResourcePool(@javax.annotation.Nullable ResourcePool resourcePool) { + this.resourcePool = resourcePool; + } + + /** + * 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 UpdateResourcePoolResponse instance itself + */ + public UpdateResourcePoolResponse 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; + } + UpdateResourcePoolResponse updateResourcePoolResponse = (UpdateResourcePoolResponse) o; + return Objects.equals(this.resourcePool, updateResourcePoolResponse.resourcePool) + && Objects.equals( + this.additionalProperties, updateResourcePoolResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(resourcePool, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateResourcePoolResponse {\n"); + sb.append(" resourcePool: ").append(toIndentedString(resourcePool)).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("resourcePool")); + + // 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 UpdateResourcePoolResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateResourcePoolResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateResourcePoolResponse is not found in the empty JSON string", + UpdateResourcePoolResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `resourcePool` + if (jsonObj.get("resourcePool") != null && !jsonObj.get("resourcePool").isJsonNull()) { + ResourcePool.validateJsonElement(jsonObj.get("resourcePool")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateResourcePoolResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateResourcePoolResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateResourcePoolResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateResourcePoolResponse 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 UpdateResourcePoolResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateResourcePoolResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateResourcePoolResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateResourcePoolResponse + * @throws IOException if the JSON string is invalid with respect to UpdateResourcePoolResponse + */ + public static UpdateResourcePoolResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateResourcePoolResponse.class); + } + + /** + * Convert an instance of UpdateResourcePoolResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyBodyRule.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyBodyRule.java new file mode 100644 index 0000000..f525c5a --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyBodyRule.java @@ -0,0 +1,474 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** UpdateShareExportPolicyBodyRule */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateShareExportPolicyBodyRule { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_IP_ACL = "ipAcl"; + + @SerializedName(SERIALIZED_NAME_IP_ACL) + @javax.annotation.Nullable private List ipAcl = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ORDER = "order"; + + @SerializedName(SERIALIZED_NAME_ORDER) + @javax.annotation.Nullable private Integer order; + + public static final String SERIALIZED_NAME_READ_ONLY = "readOnly"; + + @SerializedName(SERIALIZED_NAME_READ_ONLY) + @javax.annotation.Nullable private Boolean readOnly = false; + + public static final String SERIALIZED_NAME_SET_UUID = "setUuid"; + + @SerializedName(SERIALIZED_NAME_SET_UUID) + @javax.annotation.Nullable private Boolean setUuid = false; + + public static final String SERIALIZED_NAME_SUPER_USER = "superUser"; + + @SerializedName(SERIALIZED_NAME_SUPER_USER) + @javax.annotation.Nullable private Boolean superUser = true; + + public UpdateShareExportPolicyBodyRule() {} + + public UpdateShareExportPolicyBodyRule description( + @javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Description of the Rule (optional) + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public UpdateShareExportPolicyBodyRule ipAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + return this; + } + + public UpdateShareExportPolicyBodyRule addIpAclItem(String ipAclItem) { + if (this.ipAcl == null) { + this.ipAcl = new ArrayList<>(); + } + this.ipAcl.add(ipAclItem); + return this; + } + + /** + * IP access control list, where IPs must have a subnet mask (e.g. \"172.16.0.0/24\" + * for a range of IPs, or \"172.16.0.250/32\" for a specific IP) This array cannot be + * empty + * + * @return ipAcl + */ + @javax.annotation.Nullable public List getIpAcl() { + return ipAcl; + } + + public void setIpAcl(@javax.annotation.Nullable List ipAcl) { + this.ipAcl = ipAcl; + } + + public UpdateShareExportPolicyBodyRule order(@javax.annotation.Nullable Integer order) { + this.order = order; + return this; + } + + /** + * Order of the rule within a Share Export Policy. The order is used so that when a client IP + * matches multiple rules, the first rule is applied This field must be set + * + * @return order + */ + @javax.annotation.Nullable public Integer getOrder() { + return order; + } + + public void setOrder(@javax.annotation.Nullable Integer order) { + this.order = order; + } + + public UpdateShareExportPolicyBodyRule readOnly(@javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule can only mount the share in read only mode + * Default: false + * + * @return readOnly + */ + @javax.annotation.Nullable public Boolean getReadOnly() { + return readOnly; + } + + public void setReadOnly(@javax.annotation.Nullable Boolean readOnly) { + this.readOnly = readOnly; + } + + public UpdateShareExportPolicyBodyRule setUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + return this; + } + + /** + * Flag to honor set UUID Default: false + * + * @return setUuid + */ + @javax.annotation.Nullable public Boolean getSetUuid() { + return setUuid; + } + + public void setSetUuid(@javax.annotation.Nullable Boolean setUuid) { + this.setUuid = setUuid; + } + + public UpdateShareExportPolicyBodyRule superUser(@javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + return this; + } + + /** + * Flag to indicate if client IPs matching this rule have root access on the Share Default: true + * + * @return superUser + */ + @javax.annotation.Nullable public Boolean getSuperUser() { + return superUser; + } + + public void setSuperUser(@javax.annotation.Nullable Boolean superUser) { + this.superUser = superUser; + } + + /** + * 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 UpdateShareExportPolicyBodyRule instance itself + */ + public UpdateShareExportPolicyBodyRule 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; + } + UpdateShareExportPolicyBodyRule updateShareExportPolicyBodyRule = + (UpdateShareExportPolicyBodyRule) o; + return Objects.equals(this.description, updateShareExportPolicyBodyRule.description) + && Objects.equals(this.ipAcl, updateShareExportPolicyBodyRule.ipAcl) + && Objects.equals(this.order, updateShareExportPolicyBodyRule.order) + && Objects.equals(this.readOnly, updateShareExportPolicyBodyRule.readOnly) + && Objects.equals(this.setUuid, updateShareExportPolicyBodyRule.setUuid) + && Objects.equals(this.superUser, updateShareExportPolicyBodyRule.superUser) + && Objects.equals( + this.additionalProperties, + updateShareExportPolicyBodyRule.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + description, ipAcl, order, readOnly, setUuid, superUser, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateShareExportPolicyBodyRule {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" ipAcl: ").append(toIndentedString(ipAcl)).append("\n"); + sb.append(" order: ").append(toIndentedString(order)).append("\n"); + sb.append(" readOnly: ").append(toIndentedString(readOnly)).append("\n"); + sb.append(" setUuid: ").append(toIndentedString(setUuid)).append("\n"); + sb.append(" superUser: ").append(toIndentedString(superUser)).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", + "ipAcl", + "order", + "readOnly", + "setUuid", + "superUser")); + + // 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 + * UpdateShareExportPolicyBodyRule + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateShareExportPolicyBodyRule.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateShareExportPolicyBodyRule is not found in the empty JSON string", + UpdateShareExportPolicyBodyRule.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("ipAcl") != null + && !jsonObj.get("ipAcl").isJsonNull() + && !jsonObj.get("ipAcl").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ipAcl` to be an array in the JSON string but got `%s`", + jsonObj.get("ipAcl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateShareExportPolicyBodyRule.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateShareExportPolicyBodyRule' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(UpdateShareExportPolicyBodyRule.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateShareExportPolicyBodyRule 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 UpdateShareExportPolicyBodyRule read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateShareExportPolicyBodyRule instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateShareExportPolicyBodyRule given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateShareExportPolicyBodyRule + * @throws IOException if the JSON string is invalid with respect to + * UpdateShareExportPolicyBodyRule + */ + public static UpdateShareExportPolicyBodyRule fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateShareExportPolicyBodyRule.class); + } + + /** + * Convert an instance of UpdateShareExportPolicyBodyRule to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyPayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyPayload.java new file mode 100644 index 0000000..cff96c8 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyPayload.java @@ -0,0 +1,381 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; +import org.openapitools.jackson.nullable.JsonNullable; + +/** UpdateShareExportPolicyPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateShareExportPolicyPayload { + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_RULES = "rules"; + + @SerializedName(SERIALIZED_NAME_RULES) + @javax.annotation.Nullable private List rules; + + public UpdateShareExportPolicyPayload() {} + + public UpdateShareExportPolicyPayload labels( + @javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public UpdateShareExportPolicyPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share export policy keys + * are validated using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and + * cannot be empty values are validated using the following regex + * '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public UpdateShareExportPolicyPayload rules( + @javax.annotation.Nullable List rules) { + this.rules = rules; + return this; + } + + public UpdateShareExportPolicyPayload addRulesItem(UpdateShareExportPolicyBodyRule rulesItem) { + if (this.rules == null) { + this.rules = new ArrayList<>(); + } + this.rules.add(rulesItem); + return this; + } + + /** + * List of rules of the Share Export Policy. The order of the rules within the array does not + * matter - what matters is the field \"order\" within each rule. The whole set of + * rules needs to be sent in the same request, e.g. if 1 rule is sent, the share export policy + * will have just that 1 rule, as opposed to extending the existing set of rules with the 1 rule + * that was sent Important note: the array of rules passed always overwrites the rule array + * (i.e. sending an empty array removes all rules) + * + * @return rules + */ + @javax.annotation.Nullable public List getRules() { + return rules; + } + + public void setRules(@javax.annotation.Nullable List rules) { + this.rules = rules; + } + + /** + * 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 UpdateShareExportPolicyPayload instance itself + */ + public UpdateShareExportPolicyPayload 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; + } + UpdateShareExportPolicyPayload updateShareExportPolicyPayload = + (UpdateShareExportPolicyPayload) o; + return Objects.equals(this.labels, updateShareExportPolicyPayload.labels) + && Objects.equals(this.rules, updateShareExportPolicyPayload.rules) + && Objects.equals( + this.additionalProperties, + updateShareExportPolicyPayload.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(labels, rules, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateShareExportPolicyPayload {\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" rules: ").append(toIndentedString(rules)).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("labels", "rules")); + + // 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 + * UpdateShareExportPolicyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateShareExportPolicyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateShareExportPolicyPayload is not found in the empty JSON string", + UpdateShareExportPolicyPayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("rules") != null && !jsonObj.get("rules").isJsonNull()) { + JsonArray jsonArrayrules = jsonObj.getAsJsonArray("rules"); + if (jsonArrayrules != null) { + // ensure the json data is an array + if (!jsonObj.get("rules").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `rules` to be an array in the JSON string but got `%s`", + jsonObj.get("rules").toString())); + } + + // validate the optional field `rules` (array) + for (int i = 0; i < jsonArrayrules.size(); i++) { + UpdateShareExportPolicyBodyRule.validateJsonElement(jsonArrayrules.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateShareExportPolicyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateShareExportPolicyPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(UpdateShareExportPolicyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateShareExportPolicyPayload 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 UpdateShareExportPolicyPayload read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateShareExportPolicyPayload instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateShareExportPolicyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateShareExportPolicyPayload + * @throws IOException if the JSON string is invalid with respect to + * UpdateShareExportPolicyPayload + */ + public static UpdateShareExportPolicyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateShareExportPolicyPayload.class); + } + + /** + * Convert an instance of UpdateShareExportPolicyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyResponse.java new file mode 100644 index 0000000..59ef31b --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareExportPolicyResponse.java @@ -0,0 +1,303 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** UpdateShareExportPolicyResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateShareExportPolicyResponse { + public static final String SERIALIZED_NAME_SHARE_EXPORT_POLICY = "shareExportPolicy"; + + @SerializedName(SERIALIZED_NAME_SHARE_EXPORT_POLICY) + @javax.annotation.Nullable private ShareExportPolicy shareExportPolicy; + + public UpdateShareExportPolicyResponse() {} + + public UpdateShareExportPolicyResponse shareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + return this; + } + + /** + * Get shareExportPolicy + * + * @return shareExportPolicy + */ + @javax.annotation.Nullable public ShareExportPolicy getShareExportPolicy() { + return shareExportPolicy; + } + + public void setShareExportPolicy( + @javax.annotation.Nullable ShareExportPolicy shareExportPolicy) { + this.shareExportPolicy = shareExportPolicy; + } + + /** + * 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 UpdateShareExportPolicyResponse instance itself + */ + public UpdateShareExportPolicyResponse 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; + } + UpdateShareExportPolicyResponse updateShareExportPolicyResponse = + (UpdateShareExportPolicyResponse) o; + return Objects.equals( + this.shareExportPolicy, updateShareExportPolicyResponse.shareExportPolicy) + && Objects.equals( + this.additionalProperties, + updateShareExportPolicyResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(shareExportPolicy, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateShareExportPolicyResponse {\n"); + sb.append(" shareExportPolicy: ") + .append(toIndentedString(shareExportPolicy)) + .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("shareExportPolicy")); + + // 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 + * UpdateShareExportPolicyResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateShareExportPolicyResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateShareExportPolicyResponse is not found in the empty JSON string", + UpdateShareExportPolicyResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `shareExportPolicy` + if (jsonObj.get("shareExportPolicy") != null + && !jsonObj.get("shareExportPolicy").isJsonNull()) { + ShareExportPolicy.validateJsonElement(jsonObj.get("shareExportPolicy")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateShareExportPolicyResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateShareExportPolicyResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(UpdateShareExportPolicyResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateShareExportPolicyResponse 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 UpdateShareExportPolicyResponse read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateShareExportPolicyResponse instance = + thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateShareExportPolicyResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateShareExportPolicyResponse + * @throws IOException if the JSON string is invalid with respect to + * UpdateShareExportPolicyResponse + */ + public static UpdateShareExportPolicyResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateShareExportPolicyResponse.class); + } + + /** + * Convert an instance of UpdateShareExportPolicyResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateSharePayload.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateSharePayload.java new file mode 100644 index 0000000..2d18b16 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateSharePayload.java @@ -0,0 +1,383 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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 org.openapitools.jackson.nullable.JsonNullable; + +/** UpdateSharePayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateSharePayload { + public static final String SERIALIZED_NAME_EXPORT_POLICY_NAME = "exportPolicyName"; + + @SerializedName(SERIALIZED_NAME_EXPORT_POLICY_NAME) + @javax.annotation.Nullable private String exportPolicyName; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES = + "spaceHardLimitGigabytes"; + + @SerializedName(SERIALIZED_NAME_SPACE_HARD_LIMIT_GIGABYTES) + @javax.annotation.Nullable private Integer spaceHardLimitGigabytes; + + public UpdateSharePayload() {} + + public UpdateSharePayload exportPolicyName(@javax.annotation.Nullable String exportPolicyName) { + this.exportPolicyName = exportPolicyName; + return this; + } + + /** + * Name of the Share Export Policy to use in the Share. The behavior depends on the value: - If + * not set (null): Keep the existing export policy (if any) - If set to empty string + * (\"\"): Remove the existing export policy - If set to a policy name: Update to use + * the specified policy, creating a new association if none exists + * + * @return exportPolicyName + */ + @javax.annotation.Nullable public String getExportPolicyName() { + return exportPolicyName; + } + + public void setExportPolicyName(@javax.annotation.Nullable String exportPolicyName) { + this.exportPolicyName = exportPolicyName; + } + + public UpdateSharePayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public UpdateSharePayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * An optional object that represents the labels associated with the share keys are validated + * using the following regex '^[\\\\p{Ll}][\\\\p{Ll}\\\\p{N}_-]*$' and cannot be empty + * values are validated using the following regex '^[\\\\p{Ll}\\\\p{N}_-]*$' + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public UpdateSharePayload spaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + return this; + } + + /** + * Space hard limit for the Share. If zero, the Share will have access to the full space of the + * Resource Pool it lives in. (unit: gibibytes) + * + * @return spaceHardLimitGigabytes + */ + @javax.annotation.Nullable public Integer getSpaceHardLimitGigabytes() { + return spaceHardLimitGigabytes; + } + + public void setSpaceHardLimitGigabytes( + @javax.annotation.Nullable Integer spaceHardLimitGigabytes) { + this.spaceHardLimitGigabytes = spaceHardLimitGigabytes; + } + + /** + * 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 UpdateSharePayload instance itself + */ + public UpdateSharePayload 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; + } + UpdateSharePayload updateSharePayload = (UpdateSharePayload) o; + return Objects.equals(this.exportPolicyName, updateSharePayload.exportPolicyName) + && Objects.equals(this.labels, updateSharePayload.labels) + && Objects.equals( + this.spaceHardLimitGigabytes, updateSharePayload.spaceHardLimitGigabytes) + && Objects.equals( + this.additionalProperties, updateSharePayload.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash( + exportPolicyName, labels, spaceHardLimitGigabytes, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateSharePayload {\n"); + sb.append(" exportPolicyName: ").append(toIndentedString(exportPolicyName)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" spaceHardLimitGigabytes: ") + .append(toIndentedString(spaceHardLimitGigabytes)) + .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("exportPolicyName", "labels", "spaceHardLimitGigabytes")); + + // 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 UpdateSharePayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateSharePayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateSharePayload is not found in the empty JSON string", + UpdateSharePayload.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("exportPolicyName") != null + && !jsonObj.get("exportPolicyName").isJsonNull()) + && !jsonObj.get("exportPolicyName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `exportPolicyName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("exportPolicyName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateSharePayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateSharePayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateSharePayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateSharePayload 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 UpdateSharePayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateSharePayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateSharePayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateSharePayload + * @throws IOException if the JSON string is invalid with respect to UpdateSharePayload + */ + public static UpdateSharePayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateSharePayload.class); + } + + /** + * Convert an instance of UpdateSharePayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareResponse.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareResponse.java new file mode 100644 index 0000000..76da694 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/UpdateShareResponse.java @@ -0,0 +1,289 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** UpdateShareResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateShareResponse { + public static final String SERIALIZED_NAME_SHARE = "share"; + + @SerializedName(SERIALIZED_NAME_SHARE) + @javax.annotation.Nullable private Share share; + + public UpdateShareResponse() {} + + public UpdateShareResponse share(@javax.annotation.Nullable Share share) { + this.share = share; + return this; + } + + /** + * Updated Share + * + * @return share + */ + @javax.annotation.Nullable public Share getShare() { + return share; + } + + public void setShare(@javax.annotation.Nullable Share share) { + this.share = share; + } + + /** + * 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 UpdateShareResponse instance itself + */ + public UpdateShareResponse 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; + } + UpdateShareResponse updateShareResponse = (UpdateShareResponse) o; + return Objects.equals(this.share, updateShareResponse.share) + && Objects.equals( + this.additionalProperties, updateShareResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(share, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateShareResponse {\n"); + sb.append(" share: ").append(toIndentedString(share)).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("share")); + + // 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 UpdateShareResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateShareResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateShareResponse is not found in the empty JSON string", + UpdateShareResponse.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `share` + if (jsonObj.get("share") != null && !jsonObj.get("share").isJsonNull()) { + Share.validateJsonElement(jsonObj.get("share")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateShareResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateShareResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateShareResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateShareResponse 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 UpdateShareResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + UpdateShareResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateShareResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateShareResponse + * @throws IOException if the JSON string is invalid with respect to UpdateShareResponse + */ + public static UpdateShareResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateShareResponse.class); + } + + /** + * Convert an instance of UpdateShareResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationError.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationError.java new file mode 100644 index 0000000..4cf6185 --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationError.java @@ -0,0 +1,435 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; +import org.openapitools.jackson.nullable.JsonNullable; + +/** ValidationError */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ValidationError { + public static final String SERIALIZED_NAME_ERROR_DESCRIPTION = "error_description"; + + @Deprecated + @SerializedName(SERIALIZED_NAME_ERROR_DESCRIPTION) + @javax.annotation.Nullable private Object errorDescription; + + public static final String SERIALIZED_NAME_TITLE = "title"; + + @SerializedName(SERIALIZED_NAME_TITLE) + @javax.annotation.Nonnull + private String title; + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public static final String SERIALIZED_NAME_FIELDS = "fields"; + + @SerializedName(SERIALIZED_NAME_FIELDS) + @javax.annotation.Nonnull + private List fields = new ArrayList<>(); + + public ValidationError() {} + + @Deprecated + public ValidationError errorDescription(@javax.annotation.Nullable Object errorDescription) { + this.errorDescription = errorDescription; + return this; + } + + /** + * Human-readable string of the error that occured + * + * @return errorDescription + * @deprecated + */ + @Deprecated + @javax.annotation.Nullable public Object getErrorDescription() { + return errorDescription; + } + + @Deprecated + public void setErrorDescription(@javax.annotation.Nullable Object errorDescription) { + this.errorDescription = errorDescription; + } + + public ValidationError title(@javax.annotation.Nonnull String title) { + this.title = title; + return this; + } + + /** + * Human-readable description of the error that occurred. + * + * @return title + */ + @javax.annotation.Nonnull + public String getTitle() { + return title; + } + + public void setTitle(@javax.annotation.Nonnull String title) { + this.title = title; + } + + public ValidationError type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * URI Uniquely identifies the error type. It will be in the format of + * storage.stackit.cloud/<error-type> e.g. storage.stackit.cloud/validation-error + * + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + public ValidationError fields(@javax.annotation.Nonnull List fields) { + this.fields = fields; + return this; + } + + public ValidationError addFieldsItem(ValidationErrorField fieldsItem) { + if (this.fields == null) { + this.fields = new ArrayList<>(); + } + this.fields.add(fieldsItem); + return this; + } + + /** + * Get fields + * + * @return fields + */ + @javax.annotation.Nonnull + public List getFields() { + return fields; + } + + public void setFields(@javax.annotation.Nonnull List fields) { + this.fields = fields; + } + + /** + * 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 ValidationError instance itself + */ + public ValidationError 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; + } + ValidationError validationError = (ValidationError) o; + return Objects.equals(this.errorDescription, validationError.errorDescription) + && Objects.equals(this.title, validationError.title) + && Objects.equals(this.type, validationError.type) + && Objects.equals(this.fields, validationError.fields) + && Objects.equals(this.additionalProperties, validationError.additionalProperties); + } + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b + || (a != null + && b != null + && a.isPresent() + && b.isPresent() + && Objects.deepEquals(a.get(), b.get())); + } + + @Override + public int hashCode() { + return Objects.hash(errorDescription, title, type, fields, additionalProperties); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] {a.get()}) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ValidationError {\n"); + sb.append(" errorDescription: ").append(toIndentedString(errorDescription)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" fields: ").append(toIndentedString(fields)).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_description", "title", "type", "fields")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("title", "type", "fields")); + } + + /** + * 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 ValidationError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ValidationError.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ValidationError is not found in the empty JSON string", + ValidationError.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ValidationError.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `title` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("title").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("type").toString())); + } + // ensure the json data is an array + if (!jsonObj.get("fields").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `fields` to be an array in the JSON string but got `%s`", + jsonObj.get("fields").toString())); + } + + JsonArray jsonArrayfields = jsonObj.getAsJsonArray("fields"); + // validate the required field `fields` (array) + for (int i = 0; i < jsonArrayfields.size(); i++) { + ValidationErrorField.validateJsonElement(jsonArrayfields.get(i)); + } + ; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ValidationError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ValidationError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ValidationError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ValidationError 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 ValidationError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ValidationError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ValidationError given an JSON string + * + * @param jsonString JSON string + * @return An instance of ValidationError + * @throws IOException if the JSON string is invalid with respect to ValidationError + */ + public static ValidationError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ValidationError.class); + } + + /** + * Convert an instance of ValidationError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationErrorField.java b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationErrorField.java new file mode 100644 index 0000000..da30d3b --- /dev/null +++ b/services/sfs/src/main/java/cloud/stackit/sdk/sfs/model/ValidationErrorField.java @@ -0,0 +1,336 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.model; + +import cloud.stackit.sdk.sfs.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; + +/** ValidationErrorField */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ValidationErrorField { + public static final String SERIALIZED_NAME_FIELD = "field"; + + @SerializedName(SERIALIZED_NAME_FIELD) + @javax.annotation.Nonnull + private String field; + + public static final String SERIALIZED_NAME_REASON = "reason"; + + @SerializedName(SERIALIZED_NAME_REASON) + @javax.annotation.Nonnull + private String reason; + + public ValidationErrorField() {} + + public ValidationErrorField field(@javax.annotation.Nonnull String field) { + this.field = field; + return this; + } + + /** + * The name of the field in the request that has failed the validation + * + * @return field + */ + @javax.annotation.Nonnull + public String getField() { + return field; + } + + public void setField(@javax.annotation.Nonnull String field) { + this.field = field; + } + + public ValidationErrorField reason(@javax.annotation.Nonnull String reason) { + this.reason = reason; + return this; + } + + /** + * The reason why the validation failed + * + * @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 ValidationErrorField instance itself + */ + public ValidationErrorField 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; + } + ValidationErrorField validationErrorField = (ValidationErrorField) o; + return Objects.equals(this.field, validationErrorField.field) + && Objects.equals(this.reason, validationErrorField.reason) + && Objects.equals( + this.additionalProperties, validationErrorField.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(field, reason, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ValidationErrorField {\n"); + sb.append(" field: ").append(toIndentedString(field)).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("field", "reason")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("field", "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 ValidationErrorField + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ValidationErrorField.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ValidationErrorField is not found in the empty JSON string", + ValidationErrorField.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ValidationErrorField.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + "The required field `%s` is not found in the JSON string: %s", + requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("field").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `field` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("field").toString())); + } + if (!jsonObj.get("reason").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "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 (!ValidationErrorField.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ValidationErrorField' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ValidationErrorField.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ValidationErrorField 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 ValidationErrorField read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ValidationErrorField instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ValidationErrorField given an JSON string + * + * @param jsonString JSON string + * @return An instance of ValidationErrorField + * @throws IOException if the JSON string is invalid with respect to ValidationErrorField + */ + public static ValidationErrorField fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ValidationErrorField.class); + } + + /** + * Convert an instance of ValidationErrorField to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/DefaultApiTest.java b/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/DefaultApiTest.java new file mode 100644 index 0000000..d7a62f1 --- /dev/null +++ b/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/DefaultApiTest.java @@ -0,0 +1,66 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.auth.SetupAuth; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.utils.TestUtils; +import java.io.IOException; +import okhttp3.Authenticator; +import okhttp3.OkHttpClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class DefaultApiTest { + @Test + public void TestCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + OkHttpClient httpClient = new OkHttpClient(); + ApiClient apiClient = new ApiClient(httpClient, conf); + + // then + Assertions.assertEquals(httpClient, apiClient.getHttpClient()); + // make sure the http client object is exactly the same object + Assertions.assertSame(httpClient, apiClient.getHttpClient()); + } + + @Test + public void TestNoCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + ApiClient apiClient = new ApiClient(conf); + + // then + /* + * verify a fresh OkHttpClient got created which will have the auth header set + * by the {@link cloud.stackit.sdk.core.KeyFlowAuthenticator} + */ + OkHttpClient httpClient = new OkHttpClient(); + Authenticator authenticator = + new KeyFlowAuthenticator(httpClient, conf, SetupAuth.setupKeyFlow(conf)); + httpClient = httpClient.newBuilder().authenticator(authenticator).build(); + + Assertions.assertNotNull(apiClient.getHttpClient()); + Assertions.assertEquals( + httpClient.authenticator().getClass(), + apiClient.getHttpClient().authenticator().getClass()); + } +} diff --git a/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/SfsApiTest.java b/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/SfsApiTest.java new file mode 100644 index 0000000..8152e22 --- /dev/null +++ b/services/sfs/src/test/java/cloud/stackit/sdk/sfs/api/SfsApiTest.java @@ -0,0 +1,67 @@ +/* + * STACKIT File Storage (SFS) + * API used to create and manage NFS Shares. + * + * The version of the OpenAPI document: 1beta.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.sfs.api; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.auth.SetupAuth; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.utils.TestUtils; +import java.io.IOException; +import okhttp3.Authenticator; +import okhttp3.OkHttpClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** API tests for SfsApi */ +public class SfsApiTest { + @Test + public void TestCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + OkHttpClient httpClient = new OkHttpClient(); + SfsApi api = new SfsApi(httpClient); + + // then + Assertions.assertEquals(httpClient, api.getApiClient().getHttpClient()); + // make sure the http client object is exactly the same object + Assertions.assertSame(httpClient, api.getApiClient().getHttpClient()); + } + + @Test + public void TestNoCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + SfsApi api = new SfsApi(conf); + + // then + /* + * verify a fresh OkHttpClient got created which will have the auth header set + * by the {@link cloud.stackit.sdk.core.KeyFlowAuthenticator} + */ + OkHttpClient httpClient = new OkHttpClient(); + Authenticator authenticator = + new KeyFlowAuthenticator(httpClient, conf, SetupAuth.setupKeyFlow(conf)); + httpClient = httpClient.newBuilder().authenticator(authenticator).build(); + + Assertions.assertNotNull(api.getApiClient().getHttpClient()); + Assertions.assertEquals( + httpClient.authenticator().getClass(), + api.getApiClient().getHttpClient().authenticator().getClass()); + } +}