diff --git a/CHANGELOG.md b/CHANGELOG.md index 91f05ed1..e3d059cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,9 @@ - `automation`: - [v0.1.1](services/automation/CHANGELOG.md#v011) - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` -- `serverbackup`: - - [v0.2.1](services/serverbackup/CHANGELOG.md#v021) - - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` -- `serverupdate`: - - [v0.2.2](services/serverupdate/CHANGELOG.md#v022) - - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` +- `kms`: + - [v0.1.0](services/kms/CHANGELOG.md#v010) + - Initial onboarding of STACKIT Java SDK for STACKIT Key Management Service (KMS) - `objectstorage`: - [v0.5.0](services/objectstorage/CHANGELOG.md#v050) - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` @@ -23,6 +20,12 @@ - [v0.7.0](services/resourcemanager/CHANGELOG.md#v070) - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` - **Feature:** The `members` attribute in the `CreateProjectPayload` model class is now optional (previously required) and therefore changed from `@javax.annotation.Nonnull` to `@javax.annotation.Nullable` +- `serverbackup`: + - [v0.2.1](services/serverbackup/CHANGELOG.md#v021) + - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` +- `serverupdate`: + - [v0.2.2](services/serverupdate/CHANGELOG.md#v022) + - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` - `sfs`: - [v0.6.0](services/sfs/CHANGELOG.md#v060) - **Dependencies:** Bump `org.openapitools:jackson-databind-nullable` from `0.2.8` to `0.2.12` diff --git a/examples/kms/build.gradle b/examples/kms/build.gradle new file mode 100644 index 00000000..a2ddea57 --- /dev/null +++ b/examples/kms/build.gradle @@ -0,0 +1,6 @@ +dependencies { + implementation project (':services:kms') + implementation 'com.squareup.okhttp3:okhttp:4.12.0' +} + +ext.mainClassName = 'cloud.stackit.sdk.kms.examples.KmsExample' diff --git a/examples/kms/src/main/java/cloud/stackit/sdk/kms/examples/KmsExample.java b/examples/kms/src/main/java/cloud/stackit/sdk/kms/examples/KmsExample.java new file mode 100644 index 00000000..465e25f4 --- /dev/null +++ b/examples/kms/src/main/java/cloud/stackit/sdk/kms/examples/KmsExample.java @@ -0,0 +1,195 @@ +package cloud.stackit.sdk.kms.examples; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import cloud.stackit.sdk.kms.v1api.api.KmsApi; +import cloud.stackit.sdk.kms.v1api.model.Algorithm; +import cloud.stackit.sdk.kms.v1api.model.CreateKeyPayload; +import cloud.stackit.sdk.kms.v1api.model.CreateKeyRingPayload; +import cloud.stackit.sdk.kms.v1api.model.Key; +import cloud.stackit.sdk.kms.v1api.model.KeyList; +import cloud.stackit.sdk.kms.v1api.model.KeyRing; +import cloud.stackit.sdk.kms.v1api.model.KeyRingList; +import cloud.stackit.sdk.kms.v1api.model.Purpose; +import cloud.stackit.sdk.kms.v1api.model.Version; +import cloud.stackit.sdk.kms.v1api.model.VersionList; +import java.io.IOException; +import java.util.Objects; +import java.util.UUID; +import java.util.concurrent.TimeUnit; +import okhttp3.OkHttpClient; + +/** + * Creates a key ring and symmetric key, lists metadata, then cleans up only the created resources. + * Key deletion is scheduled by KMS; you'll have to manually delete the key and the keyring + * afterwards. + */ +@SuppressWarnings("PMD.SystemPrintln") +public final class KmsExample { + private static final String REGION = "eu01"; + private static final long WAIT_TIMEOUT_NANOS = TimeUnit.MINUTES.toNanos(10); + private static final long POLL_INTERVAL_SECONDS = 5; + + private KmsExample() {} + + public static void main(String[] args) throws IOException, ApiException, InterruptedException { + // The id of your STACKIT project, read from an environment variable for this example. + String projectIdValue = System.getenv("STACKIT_PROJECT_ID"); + if (projectIdValue == null || projectIdValue.isEmpty()) { + System.err.println("Environment variable 'STACKIT_PROJECT_ID' not found."); + return; + } + UUID projectId = UUID.fromString(projectIdValue); + + // Credentials are read from ~/.stackit/credentials.json or the environment variables + // STACKIT_SERVICE_ACCOUNT_KEY_PATH / STACKIT_SERVICE_ACCOUNT_KEY. + CoreConfiguration configuration = new CoreConfiguration(); + OkHttpClient httpClient = new OkHttpClient(); + KeyFlowAuthenticator authenticator = new KeyFlowAuthenticator(httpClient, configuration); + httpClient = + httpClient + .newBuilder() + .authenticator(authenticator) + .callTimeout(60, TimeUnit.SECONDS) + .build(); + KmsApi kmsApi = new KmsApi(httpClient); + + runExample(kmsApi, projectId); + } + + private static void runExample(KmsApi kmsApi, UUID projectId) + throws ApiException, InterruptedException { + UUID keyRingID = null; + UUID keyID = null; + System.out.println("creating key ring"); + try { + KeyRing keyRing = + kmsApi.createKeyRing( + projectId, + REGION, + new CreateKeyRingPayload() + .displayName("java-sdk-example-keyring") + .description("A Java SDK example key ring")); + keyRingID = Objects.requireNonNull(keyRing.getId()); + waitForKeyRing(kmsApi, projectId, keyRingID); + System.out.println("key ring created: " + keyRingID); + System.out.println("creating key"); + Key key = + kmsApi.createKey( + projectId, + REGION, + keyRingID, + new CreateKeyPayload() + .algorithm(Algorithm.AES_256_GCM) + .protection("software") + .purpose(Purpose.SYMMETRIC_ENCRYPT_DECRYPT) + .displayName("java-sdk-example-key") + .description("A Java SDK example key")); + keyID = Objects.requireNonNull(key.getId()); + waitForKey(kmsApi, projectId, keyRingID, keyID); + System.out.println("key created: " + keyID); + listKeyRings(kmsApi, projectId); + } finally { + if (keyID != null) { + // schedule key for deletion + System.out.println("scheduling key deletion"); + kmsApi.deleteKey(projectId, REGION, keyRingID, keyID); + System.out.println( + "Key scheduled for deletion. ⚠️ The key ring can't be deleted until the key deletion is done. This may take some days. Delete the key ring manually after this period."); + } + // key ring can only be deleted if no key exists. + if (keyRingID != null && keyID == null) { + System.out.println("deleting key ring"); + kmsApi.deleteKeyRing(projectId, REGION, keyRingID); + System.out.println("key ring deleted"); + } + } + } + + private static void waitForKeyRing(KmsApi kmsApi, UUID projectId, UUID keyRingId) + throws ApiException, InterruptedException { + waitUntil( + "key ring " + keyRingId + " to become active", + () -> { + KeyRing.StateEnum state = + kmsApi.getKeyRing(projectId, REGION, keyRingId).getState(); + if (state == KeyRing.StateEnum.ACTIVE) { + return true; + } + if (state != KeyRing.StateEnum.CREATING) { + throw new IllegalStateException("Unexpected key ring state: " + state); + } + return false; + }); + } + + private static void waitForKey(KmsApi kmsApi, UUID projectId, UUID keyRingId, UUID keyId) + throws ApiException, InterruptedException { + waitUntil( + "key " + keyId + " to become active", + () -> { + Key.StateEnum state = + kmsApi.getKey(projectId, REGION, keyRingId, keyId).getState(); + if (state == Key.StateEnum.ACTIVE) { + return true; + } + if (state != Key.StateEnum.CREATING) { + throw new IllegalStateException("Unexpected key state: " + state); + } + return false; + }); + } + + private static void waitUntil(String description, ApiCondition condition) + throws ApiException, InterruptedException { + long start = System.nanoTime(); + while (System.nanoTime() - start < WAIT_TIMEOUT_NANOS) { + if (condition.isSatisfied()) { + return; + } + TimeUnit.SECONDS.sleep(POLL_INTERVAL_SECONDS); + } + throw new IllegalStateException("Timed out waiting for " + description); + } + + @FunctionalInterface + private interface ApiCondition { + boolean isSatisfied() throws ApiException; + } + + private static void listKeyRings(KmsApi kmsApi, UUID projectId) throws ApiException { + System.out.println("List key rings:"); + KeyRingList keyRings = kmsApi.listKeyRings(projectId, REGION); + for (KeyRing keyRing : Objects.requireNonNull(keyRings.getKeyRings())) { + UUID keyRingId = Objects.requireNonNull(keyRing.getId()); + System.out.println("* Key Ring ID: " + keyRingId); + System.out.println("* Key Ring Name: " + keyRing.getDisplayName()); + System.out.println("* Key Ring State: " + keyRing.getState()); + listKeys(kmsApi, projectId, keyRingId); + } + } + + private static void listKeys(KmsApi kmsApi, UUID projectId, UUID keyRingId) + throws ApiException { + KeyList keys = kmsApi.listKeys(projectId, REGION, keyRingId); + for (Key key : Objects.requireNonNull(keys.getKeys())) { + UUID keyId = Objects.requireNonNull(key.getId()); + System.out.println(" * Key ID: " + keyId); + System.out.println(" * Key Name: " + key.getDisplayName()); + System.out.println(" * Algorithm: " + key.getAlgorithm()); + System.out.println(" * Purpose: " + key.getPurpose()); + System.out.println(" * Key State: " + key.getState()); + if (key.getState() == Key.StateEnum.DELETED) { + continue; + } + + VersionList versions = kmsApi.listVersions(projectId, REGION, keyRingId, keyId); + for (Version version : Objects.requireNonNull(versions.getVersions())) { + System.out.println(" * Version Number: " + version.getNumber()); + System.out.println(" * Version State: " + version.getState()); + System.out.println(" * Disabled: " + version.getDisabled()); + } + } + } +} diff --git a/services/kms/CHANGELOG.md b/services/kms/CHANGELOG.md new file mode 100644 index 00000000..9261f31b --- /dev/null +++ b/services/kms/CHANGELOG.md @@ -0,0 +1,2 @@ +## v0.1.0 +- Initial onboarding of STACKIT Java SDK for STACKIT Key Management Service (KMS) diff --git a/services/kms/README.md b/services/kms/README.md new file mode 100644 index 00000000..919739d4 --- /dev/null +++ b/services/kms/README.md @@ -0,0 +1,80 @@ +# STACKIT Java SDK for STACKIT Key Management Service API + +This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK. + +## Installation from Maven Central (recommended) + +The release artifacts for this SDK submodule are available on [Maven Central](https://central.sonatype.com/artifact/cloud.stackit.sdk/kms). + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + kms + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() + } + + dependencies { + implementation "cloud.stackit.sdk:kms:" + } +``` + +## 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:kms:publishToMavenLocal +``` + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + kms + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenLocal() + } + + dependencies { + implementation "cloud.stackit.sdk:kms:" + } +``` + +## Getting Started + +See the [kms examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/kms/src/main/java/cloud/stackit/sdk/kms/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/kms/VERSION b/services/kms/VERSION new file mode 100644 index 00000000..6e8bf73a --- /dev/null +++ b/services/kms/VERSION @@ -0,0 +1 @@ +0.1.0 diff --git a/services/kms/build.gradle b/services/kms/build.gradle new file mode 100644 index 00000000..aafa5f0b --- /dev/null +++ b/services/kms/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.12' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.18.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} diff --git a/services/kms/oas_commit b/services/kms/oas_commit new file mode 100644 index 00000000..f946725c --- /dev/null +++ b/services/kms/oas_commit @@ -0,0 +1 @@ +08b95d7f2e3b9c288a1b5d1f1f6d13b0632b7ad0 diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiCallback.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiCallback.java new file mode 100644 index 00000000..873986e2 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiCallback.java @@ -0,0 +1,60 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiClient.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiClient.java new file mode 100644 index 00000000..4cf21f8d --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiClient.java @@ -0,0 +1,1651 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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://kms.api.stackit.cloud"; + protected List servers = + new ArrayList( + Arrays.asList( + new ServerConfiguration( + "https://kms.api.stackit.cloud", + "No description provided", + new HashMap() { + { + put( + "region", + new ServerVariable( + "No description provided", + "global", + new HashSet())); + } + }))); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + protected boolean debugging = false; + protected Map defaultHeaderMap = new HashMap(); + protected Map defaultCookieMap = new HashMap(); + protected String tempFolderPath = null; + + protected DateFormat dateFormat; + protected DateFormat datetimeFormat; + protected boolean lenientDatetimeFormat; + protected int dateLength; + + protected InputStream sslCaCert; + protected boolean verifyingSsl; + protected KeyManager[] keyManagers; + protected String tlsServerName; + + protected OkHttpClient httpClient; + protected JSON json; + + protected HttpLoggingInterceptor loggingInterceptor; + + protected CoreConfiguration configuration; + + /** + * Basic constructor for ApiClient. + * + *

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

Not recommended for production use, use the one with the OkHttpClient parameter instead. + * + * @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(CoreConfiguration config) throws IOException { + this(null, config); + } + + /** + * Constructor for ApiClient with OkHttpClient parameter. Recommended for production use. + * + * @param httpClient a OkHttpClient object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(OkHttpClient httpClient) throws IOException { + this(httpClient, new CoreConfiguration()); + } + + /** + * Constructor for ApiClient with OkHttpClient parameter. Recommended for production use. + * + * @param httpClient a OkHttpClient object + * @param config a {@link cloud.stackit.sdk.core.config.CoreConfiguration} object + * @throws IOException thrown when a file can not be found + */ + public ApiClient(OkHttpClient httpClient, CoreConfiguration config) throws IOException { + init(); + + if (config.getCustomEndpoint() != null && !config.getCustomEndpoint().trim().isEmpty()) { + basePath = config.getCustomEndpoint(); + } + if (config.getDefaultHeader() != null) { + defaultHeaderMap = config.getDefaultHeader(); + } + this.configuration = config; + + if (httpClient == null) { + initHttpClient(); + KeyFlowAuthenticator authenticator = new KeyFlowAuthenticator(this.httpClient, config); + this.httpClient = this.httpClient.newBuilder().authenticator(authenticator).build(); + } else { + // Authorization has to be configured manually in case a custom http client object is + // passed + this.httpClient = httpClient; + } + } + + protected void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + protected void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor : interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + protected void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("stackit-sdk-java/kms"); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://kms.api.stackit.cloud) + * @return An instance of ApiClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. Default to + * true. NOTE: Do NOT set to false in production code, otherwise you would face multiple types + * of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. Use null to reset to + * default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + * Getter for the field keyManagers. + * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. Use null to reset to + * default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + * Get TLS server name for SNI (Server Name Indication). + * + * @return The TLS server name + */ + public String getTlsServerName() { + return tlsServerName; + } + + /** + * Set TLS server name for SNI (Server Name Indication). This is used to verify the server + * certificate against a specific hostname instead of the hostname in the URL. + * + * @param tlsServerName The TLS server name to use for certificate verification + * @return ApiClient + */ + public ApiClient setTlsServerName(String tlsServerName) { + this.tlsServerName = tlsServerName; + applySslSettings(); + return this; + } + + /** + * Getter for the field dateFormat. + * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + * Setter for the field dateFormat. + * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link cloud.stackit.sdk.kms.v1api.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.kms.v1api.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.kms.v1api.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.kms.v1api.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + * Set LocalDateTimeFormat. + * + * @param dateFormat a {@link java.time.format.DateTimeFormatter} object + * @return a {@link cloud.stackit.sdk.kms.v1api.ApiClient} object + */ + public ApiClient setLocalDateTimeFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateTimeFormat(dateFormat); + return this; + } + + /** + * Set LenientOnJson. + * + * @param lenientOnJson a boolean + * @return a {@link cloud.stackit.sdk.kms.v1api.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); + } + } + + /** + * Format the given parameter object as an ASCII-safe JSON string. + * + * @param param Parameter + * @return JSON representation of the parameter + */ + public String parameterToJsonString(Object param) { + if (param == null) { + return ""; + } + String json = JSON.serialize(param); + int firstUnsafe = -1; + for (int i = 0; i < json.length(); i++) { + if (json.charAt(i) >= 0x7f) { + firstUnsafe = i; + break; + } + } + if (firstUnsafe == -1) { + return json; + } + + StringBuilder escaped = new StringBuilder(json.length()); + escaped.append(json, 0, firstUnsafe); + for (int i = firstUnsafe; i < json.length(); i++) { + char c = json.charAt(i); + if (c >= 0x7f) { + escaped.append("\\u"); + escaped.append(Character.forDigit((c >> 12) & 0xf, 16)); + escaped.append(Character.forDigit((c >> 8) & 0xf, 16)); + escaped.append(Character.forDigit((c >> 4) & 0xf, 16)); + escaped.append(Character.forDigit(c & 0xf, 16)); + } else { + escaped.append(c); + } + } + + return escaped.toString(); + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + *

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

Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map)) { + return params; + } + + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceFirst("^.*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json + * application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / *" is also + * default to JSON + * + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in the given + * array, use it; otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be returned (not to + * set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given + * array, use it; otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, returns null. If it + * matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and the Content-Type + * response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to deserialize response body, + * i.e. cannot read response body or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + ResponseBody respBody = response.body(); + if (respBody == null) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + try { + if (isJsonMime(contentType)) { + if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Use String-based deserialize for String return type with fallback + return JSON.deserialize(respBodyString, returnType); + } else { + // Use InputStream-based deserialize which supports responses > 2GB + return JSON.deserialize(respBody.byteStream(), returnType); + } + } else if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Expecting string, return the raw response body. + return (T) respBodyString; + } else { + throw new ApiException( + "Content type \"" + + contentType + + "\" is not supported for type: " + + returnType, + response.code(), + response.headers().toMultimap(), + response.body().string()); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Serialize the given Java object into request body according to the object's class and the + * request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to read file content from + * response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) prefix = "download-"; + } + + if (tempFolderPath == null) return Files.createTempFile(prefix, suffix).toFile(); + else return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and data, which is a Java + * object deserialized from response body and would be null when returnType is null. + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue( + new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure( + new ApiException(e), + response.code(), + response.headers().toMultimap()); + return; + } + callback.onSuccess( + result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws cloud.stackit.sdk.core.exception.ApiException If the response has an unsuccessful + * status code or fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + throw new ApiException( + response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Call buildCall( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + Request request = + buildRequest( + baseUrl, + path, + method, + queryParams, + collectionQueryParams, + body, + headerParams, + cookieParams, + formParams, + authNames, + callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Request buildRequest( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = + RequestBody.create( + "", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + List updatedQueryParams = new ArrayList<>(queryParams); + + final Request.Builder reqBuilder = + new Request.Builder() + .url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl( + String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException( + String.format( + java.util.Locale.ROOT, + "Invalid index %d when selecting the host settings. Must be less than %d", + serverIndex, + servers.size())); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())) + .append("=") + .append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader( + "Cookie", + String.format( + java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader( + "Cookie", + String.format( + java.util.Locale.ROOT, "%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, which could + * contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item : list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = + Headers.of( + "Content-Disposition", + "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody + * Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for async + * requests. + */ + protected Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse + .newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of verifyingSsl and + * sslCaCert. + */ + protected void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = + new TrustManager[] { + new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[] {}; + } + } + }; + hostnameVerifier = + new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = + certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException( + "expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + if (tlsServerName != null && !tlsServerName.isEmpty()) { + hostnameVerifier = + new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + // Verify the certificate against tlsServerName instead of the + // actual hostname + return OkHostnameVerifier.INSTANCE.verify( + tlsServerName, session); + } + }; + } else { + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = + httpClient + .newBuilder() + .sslSocketFactory( + sslContext.getSocketFactory(), + (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object into a string + */ + protected String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiResponse.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiResponse.java new file mode 100644 index 00000000..09fd208f --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ApiResponse.java @@ -0,0 +1,73 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/GzipRequestInterceptor.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/GzipRequestInterceptor.java new file mode 100644 index 00000000..3ff5ea4f --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/GzipRequestInterceptor.java @@ -0,0 +1,87 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/JSON.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/JSON.java new file mode 100644 index 00000000..71a56dd7 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/JSON.java @@ -0,0 +1,521 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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.LocalDateTime; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +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 LocalDateTimeTypeAdapter localDateTimeTypeAdapter = + new LocalDateTimeTypeAdapter(); + 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(LocalDateTime.class, localDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.CreateKeyPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.CreateKeyRingPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.CreateWrappingKeyPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.DecryptPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.DecryptedData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.EncryptPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.EncryptedData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.HttpError.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.ImportKeyPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.Key.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.KeyList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.KeyRing.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.KeyRingList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.SignPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.SignedData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.VerifiedData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.VerifyPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.Version.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.VersionList.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.WrappingKey.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.kms.v1api.model.WrappingKeyList.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); + } + } + } + + /** Gson TypeAdapter for JSR310 LocalDateTime type */ + public static class LocalDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE_TIME); + } + + public LocalDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + return LocalDateTime.parse(date, formatter); + } catch (DateTimeParseException e) { + if (date.length() > 10 && date.charAt(10) == ' ') { + date = date.substring(0, 10) + 'T' + date.substring(11); + return LocalDateTime.parse(date, formatter); + } + throw e; + } + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateTimeFormat(DateTimeFormatter dateFormat) { + localDateTimeTypeAdapter.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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/Pair.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/Pair.java new file mode 100644 index 00000000..42ea8007 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/Pair.java @@ -0,0 +1,36 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressRequestBody.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressRequestBody.java new file mode 100644 index 00000000..c599f3eb --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressRequestBody.java @@ -0,0 +1,71 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressResponseBody.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressResponseBody.java new file mode 100644 index 00000000..10c11523 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ProgressResponseBody.java @@ -0,0 +1,68 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerConfiguration.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerConfiguration.java new file mode 100644 index 00000000..bc24a4f3 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerConfiguration.java @@ -0,0 +1,77 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +import java.util.Map; + +/** Representing a Server configuration. */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerVariable.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerVariable.java new file mode 100644 index 00000000..121c2463 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/ServerVariable.java @@ -0,0 +1,35 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +import java.util.HashSet; + +/** Representing a Server Variable for server URL template substitution. */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/StringUtil.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/StringUtil.java new file mode 100644 index 00000000..59230b8c --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/StringUtil.java @@ -0,0 +1,81 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/DefaultApi.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/DefaultApi.java new file mode 100644 index 00000000..a36f86a6 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/DefaultApi.java @@ -0,0 +1,6060 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import cloud.stackit.sdk.kms.v1api.ApiCallback; +import cloud.stackit.sdk.kms.v1api.ApiClient; +import cloud.stackit.sdk.kms.v1api.ApiResponse; +import cloud.stackit.sdk.kms.v1api.Pair; +import cloud.stackit.sdk.kms.v1api.model.CreateKeyPayload; +import cloud.stackit.sdk.kms.v1api.model.CreateKeyRingPayload; +import cloud.stackit.sdk.kms.v1api.model.CreateWrappingKeyPayload; +import cloud.stackit.sdk.kms.v1api.model.DecryptPayload; +import cloud.stackit.sdk.kms.v1api.model.DecryptedData; +import cloud.stackit.sdk.kms.v1api.model.EncryptPayload; +import cloud.stackit.sdk.kms.v1api.model.EncryptedData; +import cloud.stackit.sdk.kms.v1api.model.ImportKeyPayload; +import cloud.stackit.sdk.kms.v1api.model.Key; +import cloud.stackit.sdk.kms.v1api.model.KeyList; +import cloud.stackit.sdk.kms.v1api.model.KeyRing; +import cloud.stackit.sdk.kms.v1api.model.KeyRingList; +import cloud.stackit.sdk.kms.v1api.model.SignPayload; +import cloud.stackit.sdk.kms.v1api.model.SignedData; +import cloud.stackit.sdk.kms.v1api.model.VerifiedData; +import cloud.stackit.sdk.kms.v1api.model.VerifyPayload; +import cloud.stackit.sdk.kms.v1api.model.Version; +import cloud.stackit.sdk.kms.v1api.model.VersionList; +import cloud.stackit.sdk.kms.v1api.model.WrappingKey; +import cloud.stackit.sdk.kms.v1api.model.WrappingKeyList; +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 java.util.UUID; +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 createKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createKeyPayload (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
202 The key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateKeyPayload createKeyPayload, + 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 = createKeyPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateKeyPayload createKeyPayload, + 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 createKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling createKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling createKey(Async)"); + } + + // verify the required parameter 'createKeyPayload' is set + if (createKeyPayload == null) { + throw new ApiException( + "Missing the required parameter 'createKeyPayload' when calling createKey(Async)"); + } + + return createKeyCall(projectId, regionId, keyRingId, createKeyPayload, _callback); + } + + /** + * Create key Creates a new key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createKeyPayload (required) + * @return Key + * @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
202 The key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public Key createKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateKeyPayload createKeyPayload) + throws ApiException { + ApiResponse localVarResp = + createKeyWithHttpInfo(projectId, regionId, keyRingId, createKeyPayload); + return localVarResp.getData(); + } + + /** + * Create key Creates a new key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createKeyPayload (required) + * @return ApiResponse<Key> + * @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
202 The key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse createKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateKeyPayload createKeyPayload) + throws ApiException { + okhttp3.Call localVarCall = + createKeyValidateBeforeCall(projectId, regionId, keyRingId, createKeyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create key (asynchronously) Creates a new key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createKeyPayload (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
202 The key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateKeyPayload createKeyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createKeyValidateBeforeCall( + projectId, regionId, keyRingId, createKeyPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createKeyRing + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param createKeyRingPayload (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
202 Key ring was created successfully -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createKeyRingCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull CreateKeyRingPayload createKeyRingPayload, + 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 = createKeyRingPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createKeyRingValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull CreateKeyRingPayload createKeyRingPayload, + 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 createKeyRing(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling createKeyRing(Async)"); + } + + // verify the required parameter 'createKeyRingPayload' is set + if (createKeyRingPayload == null) { + throw new ApiException( + "Missing the required parameter 'createKeyRingPayload' when calling createKeyRing(Async)"); + } + + return createKeyRingCall(projectId, regionId, createKeyRingPayload, _callback); + } + + /** + * Create key ring Creates a new key ring within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param createKeyRingPayload (required) + * @return KeyRing + * @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
202 Key ring was created successfully -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public KeyRing createKeyRing( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull CreateKeyRingPayload createKeyRingPayload) + throws ApiException { + ApiResponse localVarResp = + createKeyRingWithHttpInfo(projectId, regionId, createKeyRingPayload); + return localVarResp.getData(); + } + + /** + * Create key ring Creates a new key ring within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param createKeyRingPayload (required) + * @return ApiResponse<KeyRing> + * @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
202 Key ring was created successfully -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse createKeyRingWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull CreateKeyRingPayload createKeyRingPayload) + throws ApiException { + okhttp3.Call localVarCall = + createKeyRingValidateBeforeCall(projectId, regionId, createKeyRingPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create key ring (asynchronously) Creates a new key ring within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param createKeyRingPayload (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
202 Key ring was created successfully -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createKeyRingAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull CreateKeyRingPayload createKeyRingPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createKeyRingValidateBeforeCall( + projectId, regionId, createKeyRingPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createWrappingKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createWrappingKeyPayload (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
202 The wrapping key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createWrappingKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateWrappingKeyPayload createWrappingKeyPayload, + 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 = createWrappingKeyPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createWrappingKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateWrappingKeyPayload createWrappingKeyPayload, + 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 createWrappingKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling createWrappingKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling createWrappingKey(Async)"); + } + + // verify the required parameter 'createWrappingKeyPayload' is set + if (createWrappingKeyPayload == null) { + throw new ApiException( + "Missing the required parameter 'createWrappingKeyPayload' when calling createWrappingKey(Async)"); + } + + return createWrappingKeyCall( + projectId, regionId, keyRingId, createWrappingKeyPayload, _callback); + } + + /** + * Create wrapping key Creates a new wrapping key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createWrappingKeyPayload (required) + * @return WrappingKey + * @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
202 The wrapping key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public WrappingKey createWrappingKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateWrappingKeyPayload createWrappingKeyPayload) + throws ApiException { + ApiResponse localVarResp = + createWrappingKeyWithHttpInfo( + projectId, regionId, keyRingId, createWrappingKeyPayload); + return localVarResp.getData(); + } + + /** + * Create wrapping key Creates a new wrapping key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createWrappingKeyPayload (required) + * @return ApiResponse<WrappingKey> + * @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
202 The wrapping key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse createWrappingKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateWrappingKeyPayload createWrappingKeyPayload) + throws ApiException { + okhttp3.Call localVarCall = + createWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, createWrappingKeyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create wrapping key (asynchronously) Creates a new wrapping key for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param createWrappingKeyPayload (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
202 The wrapping key has been created for the key ring. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call createWrappingKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull CreateWrappingKeyPayload createWrappingKeyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, createWrappingKeyPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for decrypt + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param decryptPayload (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 The decrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call decryptCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull DecryptPayload decryptPayload, + 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 = decryptPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/decrypt" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call decryptValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull DecryptPayload decryptPayload, + 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 decrypt(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling decrypt(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling decrypt(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling decrypt(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling decrypt(Async)"); + } + + // verify the required parameter 'decryptPayload' is set + if (decryptPayload == null) { + throw new ApiException( + "Missing the required parameter 'decryptPayload' when calling decrypt(Async)"); + } + + return decryptCall( + projectId, regionId, keyRingId, keyId, versionNumber, decryptPayload, _callback); + } + + /** + * Decrypt Decrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param decryptPayload (required) + * @return DecryptedData + * @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 The decrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public DecryptedData decrypt( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull DecryptPayload decryptPayload) + throws ApiException { + ApiResponse localVarResp = + decryptWithHttpInfo( + projectId, regionId, keyRingId, keyId, versionNumber, decryptPayload); + return localVarResp.getData(); + } + + /** + * Decrypt Decrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param decryptPayload (required) + * @return ApiResponse<DecryptedData> + * @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 The decrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public ApiResponse decryptWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull DecryptPayload decryptPayload) + throws ApiException { + okhttp3.Call localVarCall = + decryptValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, decryptPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Decrypt (asynchronously) Decrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param decryptPayload (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 The decrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call decryptAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull DecryptPayload decryptPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + decryptValidateBeforeCall( + projectId, + regionId, + keyRingId, + keyId, + versionNumber, + decryptPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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
202 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 deleteKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling deleteKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling deleteKey(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling deleteKey(Async)"); + } + + return deleteKeyCall(projectId, regionId, keyRingId, keyId, _callback); + } + + /** + * Delete key Schedules the deletion of the given key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
202 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void deleteKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + deleteKeyWithHttpInfo(projectId, regionId, keyRingId, keyId); + } + + /** + * Delete key Schedules the deletion of the given key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
202 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse deleteKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + okhttp3.Call localVarCall = + deleteKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete key (asynchronously) Schedules the deletion of the given key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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
202 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for deleteKeyRing + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Key ring was deleted successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteKeyRingCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteKeyRingValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 deleteKeyRing(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling deleteKeyRing(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling deleteKeyRing(Async)"); + } + + return deleteKeyRingCall(projectId, regionId, keyRingId, _callback); + } + + /** + * Delete keyring Deletes the given key ring if it is empty + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Key ring was deleted successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void deleteKeyRing( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + deleteKeyRingWithHttpInfo(projectId, regionId, keyRingId); + } + + /** + * Delete keyring Deletes the given key ring if it is empty + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Key ring was deleted successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse deleteKeyRingWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + okhttp3.Call localVarCall = + deleteKeyRingValidateBeforeCall(projectId, regionId, keyRingId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete keyring (asynchronously) Deletes the given key ring if it is empty + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Key ring was deleted successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteKeyRingAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteKeyRingValidateBeforeCall(projectId, regionId, keyRingId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for deleteWrappingKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteWrappingKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "wrappingKeyId" + "}", + localVarApiClient.escapeString(wrappingKeyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteWrappingKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + 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 deleteWrappingKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling deleteWrappingKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling deleteWrappingKey(Async)"); + } + + // verify the required parameter 'wrappingKeyId' is set + if (wrappingKeyId == null) { + throw new ApiException( + "Missing the required parameter 'wrappingKeyId' when calling deleteWrappingKey(Async)"); + } + + return deleteWrappingKeyCall(projectId, regionId, keyRingId, wrappingKeyId, _callback); + } + + /** + * Delete wrapping key Deletes the given wrapping key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void deleteWrappingKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId) + throws ApiException { + deleteWrappingKeyWithHttpInfo(projectId, regionId, keyRingId, wrappingKeyId); + } + + /** + * Delete wrapping key Deletes the given wrapping key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse deleteWrappingKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId) + throws ApiException { + okhttp3.Call localVarCall = + deleteWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, wrappingKeyId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete wrapping key (asynchronously) Deletes the given wrapping key + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 Deletion was scheduled successfully. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call deleteWrappingKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, wrappingKeyId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for destroyVersion + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully destroyed. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call destroyVersionCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/destroy" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call destroyVersionValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 destroyVersion(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling destroyVersion(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling destroyVersion(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling destroyVersion(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling destroyVersion(Async)"); + } + + return destroyVersionCall(projectId, regionId, keyRingId, keyId, versionNumber, _callback); + } + + /** + * Destroy version Removes the key material of a version permanently. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully destroyed. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void destroyVersion( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + destroyVersionWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber); + } + + /** + * Destroy version Removes the key material of a version permanently. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully destroyed. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse destroyVersionWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + okhttp3.Call localVarCall = + destroyVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Destroy version (asynchronously) Removes the key material of a version permanently. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully destroyed. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call destroyVersionAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + destroyVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for disableVersion + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully disabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call disableVersionCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/disable" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call disableVersionValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 disableVersion(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling disableVersion(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling disableVersion(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling disableVersion(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling disableVersion(Async)"); + } + + return disableVersionCall(projectId, regionId, keyRingId, keyId, versionNumber, _callback); + } + + /** + * Disable version Disables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully disabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void disableVersion( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + disableVersionWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber); + } + + /** + * Disable version Disables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully disabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse disableVersionWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + okhttp3.Call localVarCall = + disableVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Disable version (asynchronously) Disables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully disabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call disableVersionAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + disableVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for enableVersion + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully enabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call enableVersionCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/enable" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call enableVersionValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 enableVersion(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling enableVersion(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling enableVersion(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling enableVersion(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling enableVersion(Async)"); + } + + return enableVersionCall(projectId, regionId, keyRingId, keyId, versionNumber, _callback); + } + + /** + * Enable version Enables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully enabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void enableVersion( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + enableVersionWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber); + } + + /** + * Enable version Enables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully enabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse enableVersionWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + okhttp3.Call localVarCall = + enableVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Enable version (asynchronously) Enables the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully enabled. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call enableVersionAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + enableVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for encrypt + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param encryptPayload (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 The encrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call encryptCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull EncryptPayload encryptPayload, + 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 = encryptPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/encrypt" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call encryptValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull EncryptPayload encryptPayload, + 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 encrypt(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling encrypt(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling encrypt(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling encrypt(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling encrypt(Async)"); + } + + // verify the required parameter 'encryptPayload' is set + if (encryptPayload == null) { + throw new ApiException( + "Missing the required parameter 'encryptPayload' when calling encrypt(Async)"); + } + + return encryptCall( + projectId, regionId, keyRingId, keyId, versionNumber, encryptPayload, _callback); + } + + /** + * Encrypt Encrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param encryptPayload (required) + * @return EncryptedData + * @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 The encrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public EncryptedData encrypt( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull EncryptPayload encryptPayload) + throws ApiException { + ApiResponse localVarResp = + encryptWithHttpInfo( + projectId, regionId, keyRingId, keyId, versionNumber, encryptPayload); + return localVarResp.getData(); + } + + /** + * Encrypt Encrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param encryptPayload (required) + * @return ApiResponse<EncryptedData> + * @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 The encrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public ApiResponse encryptWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull EncryptPayload encryptPayload) + throws ApiException { + okhttp3.Call localVarCall = + encryptValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, encryptPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Encrypt (asynchronously) Encrypts data using the given key version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param encryptPayload (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 The encrypted data. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call encryptAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull EncryptPayload encryptPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + encryptValidateBeforeCall( + projectId, + regionId, + keyRingId, + keyId, + versionNumber, + encryptPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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 The details for the key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 getKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling getKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling getKey(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling getKey(Async)"); + } + + return getKeyCall(projectId, regionId, keyRingId, keyId, _callback); + } + + /** + * Get key Returns the details for the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return Key + * @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 The details for the key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public Key getKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + ApiResponse localVarResp = getKeyWithHttpInfo(projectId, regionId, keyRingId, keyId); + return localVarResp.getData(); + } + + /** + * Get key Returns the details for the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return ApiResponse<Key> + * @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 The details for the key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse getKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + okhttp3.Call localVarCall = + getKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get key (asynchronously) Returns the details for the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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 The details for the key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getKeyRing + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 Key ring details successfully retrieved. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getKeyRingCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getKeyRingValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 getKeyRing(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling getKeyRing(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling getKeyRing(Async)"); + } + + return getKeyRingCall(projectId, regionId, keyRingId, _callback); + } + + /** + * Get key ring Returns the details for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return KeyRing + * @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 Key ring details successfully retrieved. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public KeyRing getKeyRing( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + ApiResponse localVarResp = getKeyRingWithHttpInfo(projectId, regionId, keyRingId); + return localVarResp.getData(); + } + + /** + * Get key ring Returns the details for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return ApiResponse<KeyRing> + * @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 Key ring details successfully retrieved. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse getKeyRingWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + okhttp3.Call localVarCall = + getKeyRingValidateBeforeCall(projectId, regionId, keyRingId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get key ring (asynchronously) Returns the details for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 Key ring details successfully retrieved. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getKeyRingAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getKeyRingValidateBeforeCall(projectId, regionId, keyRingId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getVersion + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (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 The details for the version have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getVersionCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getVersionValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 getVersion(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling getVersion(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling getVersion(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling getVersion(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling getVersion(Async)"); + } + + return getVersionCall(projectId, regionId, keyRingId, keyId, versionNumber, _callback); + } + + /** + * Get version Returns the details for the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return Version + * @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 The details for the version have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public Version getVersion( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + ApiResponse localVarResp = + getVersionWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber); + return localVarResp.getData(); + } + + /** + * Get version Returns the details for the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return ApiResponse<Version> + * @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 The details for the version have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse getVersionWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + okhttp3.Call localVarCall = + getVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get version (asynchronously) Returns the details for the given version. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (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 The details for the version have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getVersionAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getWrappingKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (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 The details for the wrapping key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getWrappingKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys/{wrappingKeyId}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "wrappingKeyId" + "}", + localVarApiClient.escapeString(wrappingKeyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getWrappingKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + 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 getWrappingKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling getWrappingKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling getWrappingKey(Async)"); + } + + // verify the required parameter 'wrappingKeyId' is set + if (wrappingKeyId == null) { + throw new ApiException( + "Missing the required parameter 'wrappingKeyId' when calling getWrappingKey(Async)"); + } + + return getWrappingKeyCall(projectId, regionId, keyRingId, wrappingKeyId, _callback); + } + + /** + * Get wrapping key Returns the details for the given wrapping key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @return WrappingKey + * @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 The details for the wrapping key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public WrappingKey getWrappingKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId) + throws ApiException { + ApiResponse localVarResp = + getWrappingKeyWithHttpInfo(projectId, regionId, keyRingId, wrappingKeyId); + return localVarResp.getData(); + } + + /** + * Get wrapping key Returns the details for the given wrapping key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (required) + * @return ApiResponse<WrappingKey> + * @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 The details for the wrapping key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse getWrappingKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId) + throws ApiException { + okhttp3.Call localVarCall = + getWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, wrappingKeyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get wrapping key (asynchronously) Returns the details for the given wrapping key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param wrappingKeyId The wrapping key UUID. (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 The details for the wrapping key have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call getWrappingKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID wrappingKeyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getWrappingKeyValidateBeforeCall( + projectId, regionId, keyRingId, wrappingKeyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for importKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param importKeyPayload (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
202 The key has been imported. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call importKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull ImportKeyPayload importKeyPayload, + 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 = importKeyPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/import" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call importKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull ImportKeyPayload importKeyPayload, + 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 importKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling importKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling importKey(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling importKey(Async)"); + } + + // verify the required parameter 'importKeyPayload' is set + if (importKeyPayload == null) { + throw new ApiException( + "Missing the required parameter 'importKeyPayload' when calling importKey(Async)"); + } + + return importKeyCall(projectId, regionId, keyRingId, keyId, importKeyPayload, _callback); + } + + /** + * Import key Imports a new version to the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param importKeyPayload (required) + * @return Version + * @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
202 The key has been imported. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public Version importKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull ImportKeyPayload importKeyPayload) + throws ApiException { + ApiResponse localVarResp = + importKeyWithHttpInfo(projectId, regionId, keyRingId, keyId, importKeyPayload); + return localVarResp.getData(); + } + + /** + * Import key Imports a new version to the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param importKeyPayload (required) + * @return ApiResponse<Version> + * @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
202 The key has been imported. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse importKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull ImportKeyPayload importKeyPayload) + throws ApiException { + okhttp3.Call localVarCall = + importKeyValidateBeforeCall( + projectId, regionId, keyRingId, keyId, importKeyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Import key (asynchronously) Imports a new version to the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param importKeyPayload (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
202 The key has been imported. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call importKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull ImportKeyPayload importKeyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + importKeyValidateBeforeCall( + projectId, regionId, keyRingId, keyId, importKeyPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listKeyRings + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (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 Successful response with all key rings. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listKeyRingsCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listKeyRingsValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + 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 listKeyRings(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling listKeyRings(Async)"); + } + + return listKeyRingsCall(projectId, regionId, _callback); + } + + /** + * List key rings Returns a list of all key rings within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @return KeyRingList + * @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 Successful response with all key rings. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public KeyRingList listKeyRings( + @javax.annotation.Nonnull UUID projectId, @javax.annotation.Nonnull String regionId) + throws ApiException { + ApiResponse localVarResp = listKeyRingsWithHttpInfo(projectId, regionId); + return localVarResp.getData(); + } + + /** + * List key rings Returns a list of all key rings within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @return ApiResponse<KeyRingList> + * @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 Successful response with all key rings. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse listKeyRingsWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, @javax.annotation.Nonnull String regionId) + throws ApiException { + okhttp3.Call localVarCall = listKeyRingsValidateBeforeCall(projectId, regionId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List key rings (asynchronously) Returns a list of all key rings within the project. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (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 Successful response with all key rings. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listKeyRingsAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = listKeyRingsValidateBeforeCall(projectId, regionId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listKeys + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 All keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listKeysCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listKeysValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 listKeys(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling listKeys(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling listKeys(Async)"); + } + + return listKeysCall(projectId, regionId, keyRingId, _callback); + } + + /** + * List keys Returns the keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return KeyList + * @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 All keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public KeyList listKeys( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + ApiResponse localVarResp = listKeysWithHttpInfo(projectId, regionId, keyRingId); + return localVarResp.getData(); + } + + /** + * List keys Returns the keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return ApiResponse<KeyList> + * @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 All keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse listKeysWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + okhttp3.Call localVarCall = + listKeysValidateBeforeCall(projectId, regionId, keyRingId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List keys (asynchronously) Returns the keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 All keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listKeysAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listKeysValidateBeforeCall(projectId, regionId, keyRingId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listVersions + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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 The list of key versions have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listVersionsCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listVersionsValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 listVersions(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling listVersions(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling listVersions(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling listVersions(Async)"); + } + + return listVersionsCall(projectId, regionId, keyRingId, keyId, _callback); + } + + /** + * List versions Returns a list of all versions of a given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return VersionList + * @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 The list of key versions have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public VersionList listVersions( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + ApiResponse localVarResp = + listVersionsWithHttpInfo(projectId, regionId, keyRingId, keyId); + return localVarResp.getData(); + } + + /** + * List versions Returns a list of all versions of a given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return ApiResponse<VersionList> + * @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 The list of key versions have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse listVersionsWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + okhttp3.Call localVarCall = + listVersionsValidateBeforeCall(projectId, regionId, keyRingId, keyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List versions (asynchronously) Returns a list of all versions of a given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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 The list of key versions have been successfully returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listVersionsAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listVersionsValidateBeforeCall(projectId, regionId, keyRingId, keyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listWrappingKeys + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 All wrapping keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listWrappingKeysCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/wrappingkeys" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listWrappingKeysValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + 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 listWrappingKeys(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling listWrappingKeys(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling listWrappingKeys(Async)"); + } + + return listWrappingKeysCall(projectId, regionId, keyRingId, _callback); + } + + /** + * List wrapping keys Returns the wrapping keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return WrappingKeyList + * @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 All wrapping keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public WrappingKeyList listWrappingKeys( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + ApiResponse localVarResp = + listWrappingKeysWithHttpInfo(projectId, regionId, keyRingId); + return localVarResp.getData(); + } + + /** + * List wrapping keys Returns the wrapping keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @return ApiResponse<WrappingKeyList> + * @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 All wrapping keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse listWrappingKeysWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId) + throws ApiException { + okhttp3.Call localVarCall = + listWrappingKeysValidateBeforeCall(projectId, regionId, keyRingId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List wrapping keys (asynchronously) Returns the wrapping keys for the given key ring. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (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 All wrapping keys for the key ring have been returned. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call listWrappingKeysAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listWrappingKeysValidateBeforeCall(projectId, regionId, keyRingId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for restoreKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The key has been restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call restoreKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/restore" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 restoreKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling restoreKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling restoreKey(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling restoreKey(Async)"); + } + + return restoreKeyCall(projectId, regionId, keyRingId, keyId, _callback); + } + + /** + * Restore deleted key Restores the given key from being deleted. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The key has been restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void restoreKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + restoreKeyWithHttpInfo(projectId, regionId, keyRingId, keyId); + } + + /** + * Restore deleted key Restores the given key from being deleted. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The key has been restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse restoreKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + okhttp3.Call localVarCall = + restoreKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Restore deleted key (asynchronously) Restores the given key from being deleted. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The key has been restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call restoreKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + restoreKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for restoreVersion + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call restoreVersionCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/restore" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call restoreVersionValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + 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 restoreVersion(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling restoreVersion(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling restoreVersion(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling restoreVersion(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling restoreVersion(Async)"); + } + + return restoreVersionCall(projectId, regionId, keyRingId, keyId, versionNumber, _callback); + } + + /** + * Restore version Restores the given version from being destroyed + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public void restoreVersion( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + restoreVersionWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber); + } + + /** + * Restore version Restores the given version from being destroyed + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse restoreVersionWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber) + throws ApiException { + okhttp3.Call localVarCall = + restoreVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Restore version (asynchronously) Restores the given version from being destroyed + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
204 The version has been successfully restored. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call restoreVersionAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + restoreVersionValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + + /** + * Build call for rotateKey + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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
202 The key has been rotated. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
403 Forbidden. Requested action is not allowed to be performed on the resource. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call rotateKeyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/rotate" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call rotateKeyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + 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 rotateKey(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling rotateKey(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling rotateKey(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling rotateKey(Async)"); + } + + return rotateKeyCall(projectId, regionId, keyRingId, keyId, _callback); + } + + /** + * Rotate key Rotates the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return Version + * @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
202 The key has been rotated. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
403 Forbidden. Requested action is not allowed to be performed on the resource. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public Version rotateKey( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + ApiResponse localVarResp = + rotateKeyWithHttpInfo(projectId, regionId, keyRingId, keyId); + return localVarResp.getData(); + } + + /** + * Rotate key Rotates the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @return ApiResponse<Version> + * @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
202 The key has been rotated. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
403 Forbidden. Requested action is not allowed to be performed on the resource. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public ApiResponse rotateKeyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId) + throws ApiException { + okhttp3.Call localVarCall = + rotateKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Rotate key (asynchronously) Rotates the given key. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (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
202 The key has been rotated. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
403 Forbidden. Requested action is not allowed to be performed on the resource. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
+ */ + public okhttp3.Call rotateKeyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + rotateKeyValidateBeforeCall(projectId, regionId, keyRingId, keyId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for sign + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param signPayload (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 The message has been signed using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call signCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull SignPayload signPayload, + 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 = signPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/sign" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call signValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull SignPayload signPayload, + 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 sign(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling sign(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling sign(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling sign(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling sign(Async)"); + } + + // verify the required parameter 'signPayload' is set + if (signPayload == null) { + throw new ApiException( + "Missing the required parameter 'signPayload' when calling sign(Async)"); + } + + return signCall( + projectId, regionId, keyRingId, keyId, versionNumber, signPayload, _callback); + } + + /** + * Sign Sign data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param signPayload (required) + * @return SignedData + * @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 The message has been signed using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public SignedData sign( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull SignPayload signPayload) + throws ApiException { + ApiResponse localVarResp = + signWithHttpInfo(projectId, regionId, keyRingId, keyId, versionNumber, signPayload); + return localVarResp.getData(); + } + + /** + * Sign Sign data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param signPayload (required) + * @return ApiResponse<SignedData> + * @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 The message has been signed using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public ApiResponse signWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull SignPayload signPayload) + throws ApiException { + okhttp3.Call localVarCall = + signValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, signPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Sign (asynchronously) Sign data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param signPayload (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 The message has been signed using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call signAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull SignPayload signPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + signValidateBeforeCall( + projectId, + regionId, + keyRingId, + keyId, + versionNumber, + signPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for verify + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param verifyPayload (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 The message has verified using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call verifyCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull VerifyPayload verifyPayload, + 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 = verifyPayload; + + // create path and map variables + String localVarPath = + "/v1/projects/{projectId}/regions/{regionId}/keyrings/{keyRingId}/keys/{keyId}/versions/{versionNumber}/verify" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "regionId" + "}", + localVarApiClient.escapeString(regionId.toString())) + .replace( + "{" + "keyRingId" + "}", + localVarApiClient.escapeString(keyRingId.toString())) + .replace( + "{" + "keyId" + "}", + localVarApiClient.escapeString(keyId.toString())) + .replace( + "{" + "versionNumber" + "}", + localVarApiClient.escapeString(versionNumber.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call verifyValidateBeforeCall( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull VerifyPayload verifyPayload, + 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 verify(Async)"); + } + + // verify the required parameter 'regionId' is set + if (regionId == null) { + throw new ApiException( + "Missing the required parameter 'regionId' when calling verify(Async)"); + } + + // verify the required parameter 'keyRingId' is set + if (keyRingId == null) { + throw new ApiException( + "Missing the required parameter 'keyRingId' when calling verify(Async)"); + } + + // verify the required parameter 'keyId' is set + if (keyId == null) { + throw new ApiException( + "Missing the required parameter 'keyId' when calling verify(Async)"); + } + + // verify the required parameter 'versionNumber' is set + if (versionNumber == null) { + throw new ApiException( + "Missing the required parameter 'versionNumber' when calling verify(Async)"); + } + + // verify the required parameter 'verifyPayload' is set + if (verifyPayload == null) { + throw new ApiException( + "Missing the required parameter 'verifyPayload' when calling verify(Async)"); + } + + return verifyCall( + projectId, regionId, keyRingId, keyId, versionNumber, verifyPayload, _callback); + } + + /** + * Verify Verify data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param verifyPayload (required) + * @return VerifiedData + * @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 The message has verified using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public VerifiedData verify( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull VerifyPayload verifyPayload) + throws ApiException { + ApiResponse localVarResp = + verifyWithHttpInfo( + projectId, regionId, keyRingId, keyId, versionNumber, verifyPayload); + return localVarResp.getData(); + } + + /** + * Verify Verify data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param verifyPayload (required) + * @return ApiResponse<VerifiedData> + * @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 The message has verified using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public ApiResponse verifyWithHttpInfo( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull VerifyPayload verifyPayload) + throws ApiException { + okhttp3.Call localVarCall = + verifyValidateBeforeCall( + projectId, regionId, keyRingId, keyId, versionNumber, verifyPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Verify (asynchronously) Verify data using the given key version as secret. + * + * @param projectId The STACKIT portal project UUID the key ring is part of. (required) + * @param regionId The STACKIT region name the key ring is located in. (required) + * @param keyRingId The key ring UUID. (required) + * @param keyId The key UUID. (required) + * @param versionNumber The version number. (required) + * @param verifyPayload (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 The message has verified using the key version. -
400 Bad Request. Malformed parameters or invalid body. -
401 Unauthorized. You may have provided no or wrong credentials. -
404 Not found. Requested resource has not been found. -
409 Conflict. Requested resource encounters an issue that makes it not ready to use. -
500 Internal server error. The application experienced some unexpected situation. -
503 Operation unavailable. Key is not available to execute this operation. -
+ */ + public okhttp3.Call verifyAsync( + @javax.annotation.Nonnull UUID projectId, + @javax.annotation.Nonnull String regionId, + @javax.annotation.Nonnull UUID keyRingId, + @javax.annotation.Nonnull UUID keyId, + @javax.annotation.Nonnull Long versionNumber, + @javax.annotation.Nonnull VerifyPayload verifyPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + verifyValidateBeforeCall( + projectId, + regionId, + keyRingId, + keyId, + versionNumber, + verifyPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/KmsApi.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/KmsApi.java new file mode 100644 index 00000000..b87d82d4 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/api/KmsApi.java @@ -0,0 +1,63 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import java.io.IOException; +import okhttp3.OkHttpClient; + +public class KmsApi extends DefaultApi { + /** + * Basic constructor for KmsApi + * + *

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

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public KmsApi(CoreConfiguration configuration) throws IOException { + super(configuration); + } + + /** + * Constructor for KmsApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public KmsApi(OkHttpClient httpClient) throws IOException { + super(httpClient); + } + + /** + * Constructor for KmsApi + * + * @param httpClient OkHttpClient object + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public KmsApi(OkHttpClient httpClient, CoreConfiguration configuration) throws IOException { + super(httpClient, configuration); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AbstractOpenApiSchema.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AbstractOpenApiSchema.java new file mode 100644 index 00000000..78ed0668 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AbstractOpenApiSchema.java @@ -0,0 +1,140 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.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) { + return o == null ? "null" : 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/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AccessScope.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AccessScope.java new file mode 100644 index 00000000..4cd979b6 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/AccessScope.java @@ -0,0 +1,73 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The access scope of the key. */ +@JsonAdapter(AccessScope.Adapter.class) +public enum AccessScope { + PUBLIC("PUBLIC"), + + SNA("SNA"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + AccessScope(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AccessScope fromValue(String value) { + for (AccessScope b : AccessScope.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final AccessScope enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AccessScope read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return AccessScope.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + AccessScope.fromValue(value); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Algorithm.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Algorithm.java new file mode 100644 index 00000000..3c1028c8 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Algorithm.java @@ -0,0 +1,91 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The algorithm the key material uses. */ +@JsonAdapter(Algorithm.Adapter.class) +public enum Algorithm { + AES_256_GCM("aes_256_gcm"), + + RSA_2048_OAEP_SHA256("rsa_2048_oaep_sha256"), + + RSA_3072_OAEP_SHA256("rsa_3072_oaep_sha256"), + + RSA_4096_OAEP_SHA256("rsa_4096_oaep_sha256"), + + RSA_4096_OAEP_SHA512("rsa_4096_oaep_sha512"), + + HMAC_SHA256("hmac_sha256"), + + HMAC_SHA384("hmac_sha384"), + + HMAC_SHA512("hmac_sha512"), + + ECDSA_P256_SHA256("ecdsa_p256_sha256"), + + ECDSA_P384_SHA384("ecdsa_p384_sha384"), + + ECDSA_P521_SHA512("ecdsa_p521_sha512"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + Algorithm(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Algorithm fromValue(String value) { + for (Algorithm b : Algorithm.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final Algorithm enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public Algorithm read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return Algorithm.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + Algorithm.fromValue(value); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyPayload.java new file mode 100644 index 00000000..dd2c902f --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyPayload.java @@ -0,0 +1,505 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** CreateKeyPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class CreateKeyPayload { + public static final String SERIALIZED_NAME_ACCESS_SCOPE = "access_scope"; + + @SerializedName(SERIALIZED_NAME_ACCESS_SCOPE) + @javax.annotation.Nullable private AccessScope accessScope = AccessScope.PUBLIC; + + public static final String SERIALIZED_NAME_ALGORITHM = "algorithm"; + + @SerializedName(SERIALIZED_NAME_ALGORITHM) + @javax.annotation.Nonnull + private Algorithm algorithm; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public static final String SERIALIZED_NAME_IMPORT_ONLY = "importOnly"; + + @SerializedName(SERIALIZED_NAME_IMPORT_ONLY) + @javax.annotation.Nullable private Boolean importOnly = false; + + public static final String SERIALIZED_NAME_PROTECTION = "protection"; + + @SerializedName(SERIALIZED_NAME_PROTECTION) + @javax.annotation.Nonnull + private String protection; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nonnull + private Purpose purpose; + + public CreateKeyPayload() {} + + public CreateKeyPayload accessScope(@javax.annotation.Nullable AccessScope accessScope) { + this.accessScope = accessScope; + return this; + } + + /** + * Get accessScope + * + * @return accessScope + */ + @javax.annotation.Nullable public AccessScope getAccessScope() { + return accessScope; + } + + public void setAccessScope(@javax.annotation.Nullable AccessScope accessScope) { + this.accessScope = accessScope; + } + + public CreateKeyPayload algorithm(@javax.annotation.Nonnull Algorithm algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get algorithm + * + * @return algorithm + */ + @javax.annotation.Nonnull + public Algorithm getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(@javax.annotation.Nonnull Algorithm algorithm) { + this.algorithm = algorithm; + } + + public CreateKeyPayload description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple keys. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public CreateKeyPayload displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple keys. Valid characters: letters, digits, underscores + * and hyphens. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + public CreateKeyPayload importOnly(@javax.annotation.Nullable Boolean importOnly) { + this.importOnly = importOnly; + return this; + } + + /** + * States whether versions can be created or only imported. + * + * @return importOnly + */ + @javax.annotation.Nullable public Boolean getImportOnly() { + return importOnly; + } + + public void setImportOnly(@javax.annotation.Nullable Boolean importOnly) { + this.importOnly = importOnly; + } + + public CreateKeyPayload protection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + return this; + } + + /** + * The underlying system that is responsible for protecting the key material. Possible values + * are \"software\" or \"hsm\" + * + * @return protection + */ + @javax.annotation.Nonnull + public String getProtection() { + return protection; + } + + public void setProtection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + } + + public CreateKeyPayload purpose(@javax.annotation.Nonnull Purpose purpose) { + this.purpose = purpose; + return this; + } + + /** + * Get purpose + * + * @return purpose + */ + @javax.annotation.Nonnull + public Purpose getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nonnull Purpose purpose) { + this.purpose = purpose; + } + + /** + * 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 CreateKeyPayload instance itself + */ + public CreateKeyPayload 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; + } + CreateKeyPayload createKeyPayload = (CreateKeyPayload) o; + return Objects.equals(this.accessScope, createKeyPayload.accessScope) + && Objects.equals(this.algorithm, createKeyPayload.algorithm) + && Objects.equals(this.description, createKeyPayload.description) + && Objects.equals(this.displayName, createKeyPayload.displayName) + && Objects.equals(this.importOnly, createKeyPayload.importOnly) + && Objects.equals(this.protection, createKeyPayload.protection) + && Objects.equals(this.purpose, createKeyPayload.purpose) + && Objects.equals(this.additionalProperties, createKeyPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + accessScope, + algorithm, + description, + displayName, + importOnly, + protection, + purpose, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateKeyPayload {\n"); + sb.append(" accessScope: ").append(toIndentedString(accessScope)).append("\n"); + sb.append(" algorithm: ").append(toIndentedString(algorithm)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" importOnly: ").append(toIndentedString(importOnly)).append("\n"); + sb.append(" protection: ").append(toIndentedString(protection)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).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) { + return o == null ? "null" : 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( + "access_scope", + "algorithm", + "description", + "displayName", + "importOnly", + "protection", + "purpose")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList("algorithm", "displayName", "protection", "purpose")); + } + + /** + * 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 CreateKeyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateKeyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in CreateKeyPayload is not found in the empty JSON string", + CreateKeyPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateKeyPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `access_scope` + if (jsonObj.get("access_scope") != null && !jsonObj.get("access_scope").isJsonNull()) { + AccessScope.validateJsonElement(jsonObj.get("access_scope")); + } + // validate the required field `algorithm` + Algorithm.validateJsonElement(jsonObj.get("algorithm")); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if (!jsonObj.get("protection").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `protection` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("protection").toString())); + } + // validate the required field `purpose` + Purpose.validateJsonElement(jsonObj.get("purpose")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateKeyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateKeyPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateKeyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateKeyPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateKeyPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateKeyPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateKeyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateKeyPayload + * @throws IOException if the JSON string is invalid with respect to CreateKeyPayload + */ + public static CreateKeyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateKeyPayload.class); + } + + /** + * Convert an instance of CreateKeyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyRingPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyRingPayload.java new file mode 100644 index 00000000..732a59f3 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateKeyRingPayload.java @@ -0,0 +1,340 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** CreateKeyRingPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class CreateKeyRingPayload { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public CreateKeyRingPayload() {} + + public CreateKeyRingPayload description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple key rings. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public CreateKeyRingPayload displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple key rings. Valid characters: letters, digits, + * underscores and hyphens. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + /** + * 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 CreateKeyRingPayload instance itself + */ + public CreateKeyRingPayload 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; + } + CreateKeyRingPayload createKeyRingPayload = (CreateKeyRingPayload) o; + return Objects.equals(this.description, createKeyRingPayload.description) + && Objects.equals(this.displayName, createKeyRingPayload.displayName) + && Objects.equals( + this.additionalProperties, createKeyRingPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(description, displayName, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateKeyRingPayload {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).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) { + return o == null ? "null" : 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", "displayName")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("displayName")); + } + + /** + * 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 CreateKeyRingPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateKeyRingPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in CreateKeyRingPayload is not found in the empty JSON string", + CreateKeyRingPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateKeyRingPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateKeyRingPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateKeyRingPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateKeyRingPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateKeyRingPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateKeyRingPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateKeyRingPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateKeyRingPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateKeyRingPayload + * @throws IOException if the JSON string is invalid with respect to CreateKeyRingPayload + */ + public static CreateKeyRingPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateKeyRingPayload.class); + } + + /** + * Convert an instance of CreateKeyRingPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateWrappingKeyPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateWrappingKeyPayload.java new file mode 100644 index 00000000..7bef99ac --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/CreateWrappingKeyPayload.java @@ -0,0 +1,482 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** CreateWrappingKeyPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class CreateWrappingKeyPayload { + public static final String SERIALIZED_NAME_ACCESS_SCOPE = "access_scope"; + + @SerializedName(SERIALIZED_NAME_ACCESS_SCOPE) + @javax.annotation.Nullable private AccessScope accessScope = AccessScope.PUBLIC; + + public static final String SERIALIZED_NAME_ALGORITHM = "algorithm"; + + @SerializedName(SERIALIZED_NAME_ALGORITHM) + @javax.annotation.Nonnull + private WrappingAlgorithm algorithm; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public static final String SERIALIZED_NAME_PROTECTION = "protection"; + + @SerializedName(SERIALIZED_NAME_PROTECTION) + @javax.annotation.Nonnull + private String protection; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nonnull + private WrappingPurpose purpose; + + public CreateWrappingKeyPayload() {} + + public CreateWrappingKeyPayload accessScope( + @javax.annotation.Nullable AccessScope accessScope) { + this.accessScope = accessScope; + return this; + } + + /** + * Get accessScope + * + * @return accessScope + */ + @javax.annotation.Nullable public AccessScope getAccessScope() { + return accessScope; + } + + public void setAccessScope(@javax.annotation.Nullable AccessScope accessScope) { + this.accessScope = accessScope; + } + + public CreateWrappingKeyPayload algorithm( + @javax.annotation.Nonnull WrappingAlgorithm algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get algorithm + * + * @return algorithm + */ + @javax.annotation.Nonnull + public WrappingAlgorithm getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(@javax.annotation.Nonnull WrappingAlgorithm algorithm) { + this.algorithm = algorithm; + } + + public CreateWrappingKeyPayload description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple wrapping keys. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public CreateWrappingKeyPayload displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple wrapping keys. Valid characters: letters, digits, + * underscores and hyphens. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + public CreateWrappingKeyPayload protection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + return this; + } + + /** + * The underlying system that is responsible for protecting the key material. Possible values + * are \"software\" or \"hsm\" + * + * @return protection + */ + @javax.annotation.Nonnull + public String getProtection() { + return protection; + } + + public void setProtection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + } + + public CreateWrappingKeyPayload purpose(@javax.annotation.Nonnull WrappingPurpose purpose) { + this.purpose = purpose; + return this; + } + + /** + * Get purpose + * + * @return purpose + */ + @javax.annotation.Nonnull + public WrappingPurpose getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nonnull WrappingPurpose purpose) { + this.purpose = purpose; + } + + /** + * 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 CreateWrappingKeyPayload instance itself + */ + public CreateWrappingKeyPayload 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; + } + CreateWrappingKeyPayload createWrappingKeyPayload = (CreateWrappingKeyPayload) o; + return Objects.equals(this.accessScope, createWrappingKeyPayload.accessScope) + && Objects.equals(this.algorithm, createWrappingKeyPayload.algorithm) + && Objects.equals(this.description, createWrappingKeyPayload.description) + && Objects.equals(this.displayName, createWrappingKeyPayload.displayName) + && Objects.equals(this.protection, createWrappingKeyPayload.protection) + && Objects.equals(this.purpose, createWrappingKeyPayload.purpose) + && Objects.equals( + this.additionalProperties, createWrappingKeyPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + accessScope, + algorithm, + description, + displayName, + protection, + purpose, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateWrappingKeyPayload {\n"); + sb.append(" accessScope: ").append(toIndentedString(accessScope)).append("\n"); + sb.append(" algorithm: ").append(toIndentedString(algorithm)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" protection: ").append(toIndentedString(protection)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).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) { + return o == null ? "null" : 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( + "access_scope", + "algorithm", + "description", + "displayName", + "protection", + "purpose")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList("algorithm", "displayName", "protection", "purpose")); + } + + /** + * 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 CreateWrappingKeyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateWrappingKeyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in CreateWrappingKeyPayload is not found in the empty JSON string", + CreateWrappingKeyPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateWrappingKeyPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `access_scope` + if (jsonObj.get("access_scope") != null && !jsonObj.get("access_scope").isJsonNull()) { + AccessScope.validateJsonElement(jsonObj.get("access_scope")); + } + // validate the required field `algorithm` + WrappingAlgorithm.validateJsonElement(jsonObj.get("algorithm")); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if (!jsonObj.get("protection").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `protection` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("protection").toString())); + } + // validate the required field `purpose` + WrappingPurpose.validateJsonElement(jsonObj.get("purpose")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateWrappingKeyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateWrappingKeyPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateWrappingKeyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateWrappingKeyPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateWrappingKeyPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateWrappingKeyPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateWrappingKeyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateWrappingKeyPayload + * @throws IOException if the JSON string is invalid with respect to CreateWrappingKeyPayload + */ + public static CreateWrappingKeyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateWrappingKeyPayload.class); + } + + /** + * Convert an instance of CreateWrappingKeyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptPayload.java new file mode 100644 index 00000000..463f6fe2 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptPayload.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** DecryptPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class DecryptPayload { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public DecryptPayload() {} + + public DecryptPayload data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The data that has to be decrypted. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + /** + * 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 DecryptPayload instance itself + */ + public DecryptPayload 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; + } + DecryptPayload decryptPayload = (DecryptPayload) o; + return Arrays.equals(this.data, decryptPayload.data) + && Objects.equals(this.additionalProperties, decryptPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DecryptPayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).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) { + return o == null ? "null" : 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("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * 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 DecryptPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DecryptPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in DecryptPayload is not found in the empty JSON string", + DecryptPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DecryptPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DecryptPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DecryptPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(DecryptPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, DecryptPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DecryptPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecryptPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of DecryptPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of DecryptPayload + * @throws IOException if the JSON string is invalid with respect to DecryptPayload + */ + public static DecryptPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DecryptPayload.class); + } + + /** + * Convert an instance of DecryptPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptedData.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptedData.java new file mode 100644 index 00000000..8b210037 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/DecryptedData.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** DecryptedData */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class DecryptedData { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public DecryptedData() {} + + public DecryptedData data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The decrypted data. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + /** + * 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 DecryptedData instance itself + */ + public DecryptedData 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; + } + DecryptedData decryptedData = (DecryptedData) o; + return Arrays.equals(this.data, decryptedData.data) + && Objects.equals(this.additionalProperties, decryptedData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DecryptedData {\n"); + sb.append(" data: ").append(toIndentedString(data)).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) { + return o == null ? "null" : 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("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * 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 DecryptedData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!DecryptedData.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in DecryptedData is not found in the empty JSON string", + DecryptedData.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : DecryptedData.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!DecryptedData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'DecryptedData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(DecryptedData.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, DecryptedData 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public DecryptedData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + DecryptedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of DecryptedData given an JSON string + * + * @param jsonString JSON string + * @return An instance of DecryptedData + * @throws IOException if the JSON string is invalid with respect to DecryptedData + */ + public static DecryptedData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, DecryptedData.class); + } + + /** + * Convert an instance of DecryptedData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptPayload.java new file mode 100644 index 00000000..8c2dcf20 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptPayload.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** EncryptPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class EncryptPayload { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public EncryptPayload() {} + + public EncryptPayload data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The data that has to be encrypted. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + /** + * 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 EncryptPayload instance itself + */ + public EncryptPayload 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; + } + EncryptPayload encryptPayload = (EncryptPayload) o; + return Arrays.equals(this.data, encryptPayload.data) + && Objects.equals(this.additionalProperties, encryptPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EncryptPayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).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) { + return o == null ? "null" : 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("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * 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 EncryptPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EncryptPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in EncryptPayload is not found in the empty JSON string", + EncryptPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EncryptPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EncryptPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EncryptPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(EncryptPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, EncryptPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EncryptPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EncryptPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of EncryptPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of EncryptPayload + * @throws IOException if the JSON string is invalid with respect to EncryptPayload + */ + public static EncryptPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EncryptPayload.class); + } + + /** + * Convert an instance of EncryptPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptedData.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptedData.java new file mode 100644 index 00000000..5c3b2501 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/EncryptedData.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** EncryptedData */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class EncryptedData { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public EncryptedData() {} + + public EncryptedData data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The encrypted data. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + /** + * 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 EncryptedData instance itself + */ + public EncryptedData 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; + } + EncryptedData encryptedData = (EncryptedData) o; + return Arrays.equals(this.data, encryptedData.data) + && Objects.equals(this.additionalProperties, encryptedData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EncryptedData {\n"); + sb.append(" data: ").append(toIndentedString(data)).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) { + return o == null ? "null" : 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("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * 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 EncryptedData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EncryptedData.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in EncryptedData is not found in the empty JSON string", + EncryptedData.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EncryptedData.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EncryptedData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EncryptedData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(EncryptedData.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, EncryptedData 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EncryptedData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EncryptedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of EncryptedData given an JSON string + * + * @param jsonString JSON string + * @return An instance of EncryptedData + * @throws IOException if the JSON string is invalid with respect to EncryptedData + */ + public static EncryptedData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EncryptedData.class); + } + + /** + * Convert an instance of EncryptedData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/HttpError.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/HttpError.java new file mode 100644 index 00000000..8efa8023 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/HttpError.java @@ -0,0 +1,304 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** HttpError */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class HttpError { + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nonnull + private String message; + + public HttpError() {} + + public HttpError message(@javax.annotation.Nonnull String message) { + this.message = message; + return this; + } + + /** + * A string that gives a short information about what went wrong. + * + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nonnull 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 HttpError instance itself + */ + public HttpError 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; + } + HttpError httpError = (HttpError) o; + return Objects.equals(this.message, httpError.message) + && Objects.equals(this.additionalProperties, httpError.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(message, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HttpError {\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) { + return o == null ? "null" : 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("message")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("message")); + } + + /** + * 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 HttpError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!HttpError.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in HttpError is not found in the empty JSON string", + HttpError.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : HttpError.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `message` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!HttpError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'HttpError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(HttpError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, HttpError 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public HttpError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + HttpError instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of HttpError given an JSON string + * + * @param jsonString JSON string + * @return An instance of HttpError + * @throws IOException if the JSON string is invalid with respect to HttpError + */ + public static HttpError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, HttpError.class); + } + + /** + * Convert an instance of HttpError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/ImportKeyPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/ImportKeyPayload.java new file mode 100644 index 00000000..34dbf108 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/ImportKeyPayload.java @@ -0,0 +1,340 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** ImportKeyPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class ImportKeyPayload { + public static final String SERIALIZED_NAME_WRAPPED_KEY = "wrappedKey"; + + @SerializedName(SERIALIZED_NAME_WRAPPED_KEY) + @javax.annotation.Nonnull + private String wrappedKey; + + public static final String SERIALIZED_NAME_WRAPPING_KEY_ID = "wrappingKeyId"; + + @SerializedName(SERIALIZED_NAME_WRAPPING_KEY_ID) + @javax.annotation.Nonnull + private UUID wrappingKeyId; + + public ImportKeyPayload() {} + + public ImportKeyPayload wrappedKey(@javax.annotation.Nonnull String wrappedKey) { + this.wrappedKey = wrappedKey; + return this; + } + + /** + * The wrapped key material that has to be imported. Encoded in base64. + * + * @return wrappedKey + */ + @javax.annotation.Nonnull + public String getWrappedKey() { + return wrappedKey; + } + + public void setWrappedKey(@javax.annotation.Nonnull String wrappedKey) { + this.wrappedKey = wrappedKey; + } + + public ImportKeyPayload wrappingKeyId(@javax.annotation.Nonnull UUID wrappingKeyId) { + this.wrappingKeyId = wrappingKeyId; + return this; + } + + /** + * The unique id of the wrapping key the key material has been wrapped with. + * + * @return wrappingKeyId + */ + @javax.annotation.Nonnull + public UUID getWrappingKeyId() { + return wrappingKeyId; + } + + public void setWrappingKeyId(@javax.annotation.Nonnull UUID wrappingKeyId) { + this.wrappingKeyId = wrappingKeyId; + } + + /** + * 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 ImportKeyPayload instance itself + */ + public ImportKeyPayload 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; + } + ImportKeyPayload importKeyPayload = (ImportKeyPayload) o; + return Objects.equals(this.wrappedKey, importKeyPayload.wrappedKey) + && Objects.equals(this.wrappingKeyId, importKeyPayload.wrappingKeyId) + && Objects.equals(this.additionalProperties, importKeyPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(wrappedKey, wrappingKeyId, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ImportKeyPayload {\n"); + sb.append(" wrappedKey: ").append(toIndentedString(wrappedKey)).append("\n"); + sb.append(" wrappingKeyId: ").append(toIndentedString(wrappingKeyId)).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) { + return o == null ? "null" : 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("wrappedKey", "wrappingKeyId")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("wrappedKey", "wrappingKeyId")); + } + + /** + * 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 ImportKeyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ImportKeyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in ImportKeyPayload is not found in the empty JSON string", + ImportKeyPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ImportKeyPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("wrappedKey").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `wrappedKey` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("wrappedKey").toString())); + } + if (!jsonObj.get("wrappingKeyId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `wrappingKeyId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("wrappingKeyId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ImportKeyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ImportKeyPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ImportKeyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ImportKeyPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ImportKeyPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ImportKeyPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of ImportKeyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of ImportKeyPayload + * @throws IOException if the JSON string is invalid with respect to ImportKeyPayload + */ + public static ImportKeyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ImportKeyPayload.class); + } + + /** + * Convert an instance of ImportKeyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Key.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Key.java new file mode 100644 index 00000000..7eac5036 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Key.java @@ -0,0 +1,745 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** Key */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class Key { + public static final String SERIALIZED_NAME_ACCESS_SCOPE = "access_scope"; + + @SerializedName(SERIALIZED_NAME_ACCESS_SCOPE) + @javax.annotation.Nonnull + private AccessScope accessScope = AccessScope.PUBLIC; + + public static final String SERIALIZED_NAME_ALGORITHM = "algorithm"; + + @SerializedName(SERIALIZED_NAME_ALGORITHM) + @javax.annotation.Nonnull + private Algorithm algorithm; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nonnull + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_DELETION_DATE = "deletionDate"; + + @SerializedName(SERIALIZED_NAME_DELETION_DATE) + @javax.annotation.Nullable private OffsetDateTime deletionDate; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_IMPORT_ONLY = "importOnly"; + + @SerializedName(SERIALIZED_NAME_IMPORT_ONLY) + @javax.annotation.Nonnull + private Boolean importOnly = false; + + public static final String SERIALIZED_NAME_KEY_RING_ID = "keyRingId"; + + @SerializedName(SERIALIZED_NAME_KEY_RING_ID) + @javax.annotation.Nonnull + private UUID keyRingId; + + public static final String SERIALIZED_NAME_PROTECTION = "protection"; + + @SerializedName(SERIALIZED_NAME_PROTECTION) + @javax.annotation.Nonnull + private String protection; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nonnull + private Purpose purpose; + + /** The current state of the key. */ + @JsonAdapter(StateEnum.Adapter.class) + public enum StateEnum { + ACTIVE("active"), + + DELETED("deleted"), + + NOT_AVAILABLE("not_available"), + + ERRORS_EXIST("errors_exist"), + + CREATING("creating"), + + NO_VERSION("no_version"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StateEnum fromValue(String value) { + for (StateEnum b : StateEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StateEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StateEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StateEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StateEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nonnull + private StateEnum state; + + public Key() {} + + public Key accessScope(@javax.annotation.Nonnull AccessScope accessScope) { + this.accessScope = accessScope; + return this; + } + + /** + * Get accessScope + * + * @return accessScope + */ + @javax.annotation.Nonnull + public AccessScope getAccessScope() { + return accessScope; + } + + public void setAccessScope(@javax.annotation.Nonnull AccessScope accessScope) { + this.accessScope = accessScope; + } + + public Key algorithm(@javax.annotation.Nonnull Algorithm algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get algorithm + * + * @return algorithm + */ + @javax.annotation.Nonnull + public Algorithm getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(@javax.annotation.Nonnull Algorithm algorithm) { + this.algorithm = algorithm; + } + + public Key createdAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The date and time the creation of the key was triggered. + * + * @return createdAt + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public Key deletionDate(@javax.annotation.Nullable OffsetDateTime deletionDate) { + this.deletionDate = deletionDate; + return this; + } + + /** + * This date is set when a key is pending deletion and refers to the scheduled date of deletion + * + * @return deletionDate + */ + @javax.annotation.Nullable public OffsetDateTime getDeletionDate() { + return deletionDate; + } + + public void setDeletionDate(@javax.annotation.Nullable OffsetDateTime deletionDate) { + this.deletionDate = deletionDate; + } + + public Key description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple keys. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public Key displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple keys. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + public Key id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * A auto generated unique id which identifies the keys. + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public Key importOnly(@javax.annotation.Nonnull Boolean importOnly) { + this.importOnly = importOnly; + return this; + } + + /** + * States whether versions can be created or only imported. + * + * @return importOnly + */ + @javax.annotation.Nonnull + public Boolean getImportOnly() { + return importOnly; + } + + public void setImportOnly(@javax.annotation.Nonnull Boolean importOnly) { + this.importOnly = importOnly; + } + + public Key keyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + return this; + } + + /** + * The unique id of the key ring this key is assigned to. + * + * @return keyRingId + */ + @javax.annotation.Nonnull + public UUID getKeyRingId() { + return keyRingId; + } + + public void setKeyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + } + + public Key protection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + return this; + } + + /** + * The underlying system that is responsible for protecting the key material. Possible values + * are \"software\" or \"hsm\" + * + * @return protection + */ + @javax.annotation.Nonnull + public String getProtection() { + return protection; + } + + public void setProtection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + } + + public Key purpose(@javax.annotation.Nonnull Purpose purpose) { + this.purpose = purpose; + return this; + } + + /** + * Get purpose + * + * @return purpose + */ + @javax.annotation.Nonnull + public Purpose getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nonnull Purpose purpose) { + this.purpose = purpose; + } + + public Key state(@javax.annotation.Nonnull StateEnum state) { + this.state = state; + return this; + } + + /** + * The current state of the key. + * + * @return state + */ + @javax.annotation.Nonnull + public StateEnum getState() { + return state; + } + + public void setState(@javax.annotation.Nonnull StateEnum 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 Key instance itself + */ + public Key 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; + } + Key key = (Key) o; + return Objects.equals(this.accessScope, key.accessScope) + && Objects.equals(this.algorithm, key.algorithm) + && Objects.equals(this.createdAt, key.createdAt) + && Objects.equals(this.deletionDate, key.deletionDate) + && Objects.equals(this.description, key.description) + && Objects.equals(this.displayName, key.displayName) + && Objects.equals(this.id, key.id) + && Objects.equals(this.importOnly, key.importOnly) + && Objects.equals(this.keyRingId, key.keyRingId) + && Objects.equals(this.protection, key.protection) + && Objects.equals(this.purpose, key.purpose) + && Objects.equals(this.state, key.state) + && Objects.equals(this.additionalProperties, key.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + accessScope, + algorithm, + createdAt, + deletionDate, + description, + displayName, + id, + importOnly, + keyRingId, + protection, + purpose, + state, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Key {\n"); + sb.append(" accessScope: ").append(toIndentedString(accessScope)).append("\n"); + sb.append(" algorithm: ").append(toIndentedString(algorithm)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" deletionDate: ").append(toIndentedString(deletionDate)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" importOnly: ").append(toIndentedString(importOnly)).append("\n"); + sb.append(" keyRingId: ").append(toIndentedString(keyRingId)).append("\n"); + sb.append(" protection: ").append(toIndentedString(protection)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).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) { + return o == null ? "null" : 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( + "access_scope", + "algorithm", + "createdAt", + "deletionDate", + "description", + "displayName", + "id", + "importOnly", + "keyRingId", + "protection", + "purpose", + "state")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList( + "access_scope", + "algorithm", + "createdAt", + "displayName", + "id", + "importOnly", + "keyRingId", + "protection", + "purpose", + "state")); + } + + /** + * 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 Key + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Key.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in Key is not found in the empty JSON string", + Key.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Key.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `access_scope` + AccessScope.validateJsonElement(jsonObj.get("access_scope")); + // validate the required field `algorithm` + Algorithm.validateJsonElement(jsonObj.get("algorithm")); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if (!jsonObj.get("keyRingId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keyRingId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("keyRingId").toString())); + } + if (!jsonObj.get("protection").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `protection` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("protection").toString())); + } + // validate the required field `purpose` + Purpose.validateJsonElement(jsonObj.get("purpose")); + if (!jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + // validate the required field `state` + StateEnum.validateJsonElement(jsonObj.get("state")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Key.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Key' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Key.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Key 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Key read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Key instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of Key given an JSON string + * + * @param jsonString JSON string + * @return An instance of Key + * @throws IOException if the JSON string is invalid with respect to Key + */ + public static Key fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Key.class); + } + + /** + * Convert an instance of Key to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyList.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyList.java new file mode 100644 index 00000000..8bf67608 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyList.java @@ -0,0 +1,321 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** KeyList */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class KeyList { + public static final String SERIALIZED_NAME_KEYS = "keys"; + + @SerializedName(SERIALIZED_NAME_KEYS) + @javax.annotation.Nonnull + private List keys = new ArrayList<>(); + + public KeyList() {} + + public KeyList keys(@javax.annotation.Nonnull List keys) { + this.keys = keys; + return this; + } + + public KeyList addKeysItem(Key keysItem) { + if (this.keys == null) { + this.keys = new ArrayList<>(); + } + this.keys.add(keysItem); + return this; + } + + /** + * Get keys + * + * @return keys + */ + @javax.annotation.Nonnull + public List getKeys() { + return keys; + } + + public void setKeys(@javax.annotation.Nonnull List keys) { + this.keys = keys; + } + + /** + * 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 KeyList instance itself + */ + public KeyList 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; + } + KeyList keyList = (KeyList) o; + return Objects.equals(this.keys, keyList.keys) + && Objects.equals(this.additionalProperties, keyList.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(keys, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class KeyList {\n"); + sb.append(" keys: ").append(toIndentedString(keys)).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) { + return o == null ? "null" : 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("keys")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("keys")); + } + + /** + * 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 KeyList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!KeyList.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in KeyList is not found in the empty JSON string", + KeyList.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : KeyList.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("keys") != null) { + if (!jsonObj.get("keys").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keys` to be an array in the JSON string but got `%s`", + jsonObj.get("keys").toString())); + } + JsonArray jsonArraykeys = jsonObj.getAsJsonArray("keys"); + // validate the required field `keys` (array) + for (int i = 0; i < jsonArraykeys.size(); i++) { + Key.validateJsonElement(jsonArraykeys.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!KeyList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'KeyList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(KeyList.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, KeyList 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public KeyList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + KeyList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of KeyList given an JSON string + * + * @param jsonString JSON string + * @return An instance of KeyList + * @throws IOException if the JSON string is invalid with respect to KeyList + */ + public static KeyList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, KeyList.class); + } + + /** + * Convert an instance of KeyList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRing.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRing.java new file mode 100644 index 00000000..9a594ed0 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRing.java @@ -0,0 +1,495 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** KeyRing */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class KeyRing { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nonnull + 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_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + /** The current state of the key ring. */ + @JsonAdapter(StateEnum.Adapter.class) + public enum StateEnum { + CREATING("creating"), + + ACTIVE("active"), + + DELETED("deleted"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StateEnum fromValue(String value) { + for (StateEnum b : StateEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StateEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StateEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StateEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StateEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nonnull + private StateEnum state; + + public KeyRing() {} + + public KeyRing createdAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The date and time the creation of the key ring was triggered. + * + * @return createdAt + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public KeyRing description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple key rings. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public KeyRing displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple key rings. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + public KeyRing id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * A auto generated unique id which identifies the key ring. + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public KeyRing state(@javax.annotation.Nonnull StateEnum state) { + this.state = state; + return this; + } + + /** + * The current state of the key ring. + * + * @return state + */ + @javax.annotation.Nonnull + public StateEnum getState() { + return state; + } + + public void setState(@javax.annotation.Nonnull StateEnum 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 KeyRing instance itself + */ + public KeyRing 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; + } + KeyRing keyRing = (KeyRing) o; + return Objects.equals(this.createdAt, keyRing.createdAt) + && Objects.equals(this.description, keyRing.description) + && Objects.equals(this.displayName, keyRing.displayName) + && Objects.equals(this.id, keyRing.id) + && Objects.equals(this.state, keyRing.state) + && Objects.equals(this.additionalProperties, keyRing.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, description, displayName, id, state, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class KeyRing {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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) { + return o == null ? "null" : 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", "displayName", "id", "state")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet(Arrays.asList("createdAt", "displayName", "id", "state")); + } + + /** + * 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 KeyRing + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!KeyRing.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in KeyRing is not found in the empty JSON string", + KeyRing.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : KeyRing.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if (!jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + // validate the required field `state` + StateEnum.validateJsonElement(jsonObj.get("state")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!KeyRing.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'KeyRing' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(KeyRing.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, KeyRing 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public KeyRing read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + KeyRing instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of KeyRing given an JSON string + * + * @param jsonString JSON string + * @return An instance of KeyRing + * @throws IOException if the JSON string is invalid with respect to KeyRing + */ + public static KeyRing fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, KeyRing.class); + } + + /** + * Convert an instance of KeyRing to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRingList.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRingList.java new file mode 100644 index 00000000..9a29a2a3 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/KeyRingList.java @@ -0,0 +1,321 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** KeyRingList */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class KeyRingList { + public static final String SERIALIZED_NAME_KEY_RINGS = "keyRings"; + + @SerializedName(SERIALIZED_NAME_KEY_RINGS) + @javax.annotation.Nonnull + private List keyRings = new ArrayList<>(); + + public KeyRingList() {} + + public KeyRingList keyRings(@javax.annotation.Nonnull List keyRings) { + this.keyRings = keyRings; + return this; + } + + public KeyRingList addKeyRingsItem(KeyRing keyRingsItem) { + if (this.keyRings == null) { + this.keyRings = new ArrayList<>(); + } + this.keyRings.add(keyRingsItem); + return this; + } + + /** + * Get keyRings + * + * @return keyRings + */ + @javax.annotation.Nonnull + public List getKeyRings() { + return keyRings; + } + + public void setKeyRings(@javax.annotation.Nonnull List keyRings) { + this.keyRings = keyRings; + } + + /** + * 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 KeyRingList instance itself + */ + public KeyRingList 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; + } + KeyRingList keyRingList = (KeyRingList) o; + return Objects.equals(this.keyRings, keyRingList.keyRings) + && Objects.equals(this.additionalProperties, keyRingList.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(keyRings, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class KeyRingList {\n"); + sb.append(" keyRings: ").append(toIndentedString(keyRings)).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) { + return o == null ? "null" : 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("keyRings")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("keyRings")); + } + + /** + * 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 KeyRingList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!KeyRingList.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in KeyRingList is not found in the empty JSON string", + KeyRingList.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : KeyRingList.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("keyRings") != null) { + if (!jsonObj.get("keyRings").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keyRings` to be an array in the JSON string but got `%s`", + jsonObj.get("keyRings").toString())); + } + JsonArray jsonArraykeyRings = jsonObj.getAsJsonArray("keyRings"); + // validate the required field `keyRings` (array) + for (int i = 0; i < jsonArraykeyRings.size(); i++) { + KeyRing.validateJsonElement(jsonArraykeyRings.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!KeyRingList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'KeyRingList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(KeyRingList.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, KeyRingList 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public KeyRingList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + KeyRingList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of KeyRingList given an JSON string + * + * @param jsonString JSON string + * @return An instance of KeyRingList + * @throws IOException if the JSON string is invalid with respect to KeyRingList + */ + public static KeyRingList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, KeyRingList.class); + } + + /** + * Convert an instance of KeyRingList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Purpose.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Purpose.java new file mode 100644 index 00000000..183870fa --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Purpose.java @@ -0,0 +1,77 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The purpose of the key. */ +@JsonAdapter(Purpose.Adapter.class) +public enum Purpose { + SYMMETRIC_ENCRYPT_DECRYPT("symmetric_encrypt_decrypt"), + + ASYMMETRIC_ENCRYPT_DECRYPT("asymmetric_encrypt_decrypt"), + + MESSAGE_AUTHENTICATION_CODE("message_authentication_code"), + + ASYMMETRIC_SIGN_VERIFY("asymmetric_sign_verify"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + Purpose(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static Purpose fromValue(String value) { + for (Purpose b : Purpose.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final Purpose enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public Purpose read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return Purpose.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + Purpose.fromValue(value); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignPayload.java new file mode 100644 index 00000000..fad80e4f --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignPayload.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** SignPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class SignPayload { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public SignPayload() {} + + public SignPayload data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The data that has to be signed. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + /** + * 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 SignPayload instance itself + */ + public SignPayload 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; + } + SignPayload signPayload = (SignPayload) o; + return Arrays.equals(this.data, signPayload.data) + && Objects.equals(this.additionalProperties, signPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(Arrays.hashCode(data), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SignPayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).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) { + return o == null ? "null" : 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("data")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data")); + } + + /** + * 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 SignPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SignPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in SignPayload is not found in the empty JSON string", + SignPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SignPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SignPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SignPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(SignPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, SignPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SignPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of SignPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of SignPayload + * @throws IOException if the JSON string is invalid with respect to SignPayload + */ + public static SignPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SignPayload.class); + } + + /** + * Convert an instance of SignPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignedData.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignedData.java new file mode 100644 index 00000000..7d248702 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/SignedData.java @@ -0,0 +1,325 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** SignedData */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class SignedData { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public static final String SERIALIZED_NAME_SIGNATURE = "signature"; + + @SerializedName(SERIALIZED_NAME_SIGNATURE) + @javax.annotation.Nonnull + private byte[] signature; + + public SignedData() {} + + public SignedData data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The data that was signed. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + public SignedData signature(@javax.annotation.Nonnull byte[] signature) { + this.signature = signature; + return this; + } + + /** + * The signature of the data. Encoded in base64. + * + * @return signature + */ + @javax.annotation.Nonnull + public byte[] getSignature() { + return signature; + } + + public void setSignature(@javax.annotation.Nonnull byte[] signature) { + this.signature = signature; + } + + /** + * 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 SignedData instance itself + */ + public SignedData 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; + } + SignedData signedData = (SignedData) o; + return Arrays.equals(this.data, signedData.data) + && Arrays.equals(this.signature, signedData.signature) + && Objects.equals(this.additionalProperties, signedData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(data), Arrays.hashCode(signature), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SignedData {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" signature: ").append(toIndentedString(signature)).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) { + return o == null ? "null" : 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("data", "signature")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data", "signature")); + } + + /** + * 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 SignedData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SignedData.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in SignedData is not found in the empty JSON string", + SignedData.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : SignedData.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SignedData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SignedData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(SignedData.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, SignedData 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SignedData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SignedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of SignedData given an JSON string + * + * @param jsonString JSON string + * @return An instance of SignedData + * @throws IOException if the JSON string is invalid with respect to SignedData + */ + public static SignedData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SignedData.class); + } + + /** + * Convert an instance of SignedData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifiedData.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifiedData.java new file mode 100644 index 00000000..32a3f7a8 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifiedData.java @@ -0,0 +1,297 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** VerifiedData */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class VerifiedData { + public static final String SERIALIZED_NAME_VALID = "valid"; + + @SerializedName(SERIALIZED_NAME_VALID) + @javax.annotation.Nonnull + private Boolean valid; + + public VerifiedData() {} + + public VerifiedData valid(@javax.annotation.Nonnull Boolean valid) { + this.valid = valid; + return this; + } + + /** + * Whether or not the data has a valid signature. + * + * @return valid + */ + @javax.annotation.Nonnull + public Boolean getValid() { + return valid; + } + + public void setValid(@javax.annotation.Nonnull Boolean valid) { + this.valid = valid; + } + + /** + * 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 VerifiedData instance itself + */ + public VerifiedData 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; + } + VerifiedData verifiedData = (VerifiedData) o; + return Objects.equals(this.valid, verifiedData.valid) + && Objects.equals(this.additionalProperties, verifiedData.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(valid, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerifiedData {\n"); + sb.append(" valid: ").append(toIndentedString(valid)).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) { + return o == null ? "null" : 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("valid")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("valid")); + } + + /** + * 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 VerifiedData + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!VerifiedData.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in VerifiedData is not found in the empty JSON string", + VerifiedData.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : VerifiedData.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!VerifiedData.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'VerifiedData' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(VerifiedData.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, VerifiedData 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public VerifiedData read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VerifiedData instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of VerifiedData given an JSON string + * + * @param jsonString JSON string + * @return An instance of VerifiedData + * @throws IOException if the JSON string is invalid with respect to VerifiedData + */ + public static VerifiedData fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, VerifiedData.class); + } + + /** + * Convert an instance of VerifiedData to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifyPayload.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifyPayload.java new file mode 100644 index 00000000..31f2ad96 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VerifyPayload.java @@ -0,0 +1,325 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** VerifyPayload */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class VerifyPayload { + public static final String SERIALIZED_NAME_DATA = "data"; + + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private byte[] data; + + public static final String SERIALIZED_NAME_SIGNATURE = "signature"; + + @SerializedName(SERIALIZED_NAME_SIGNATURE) + @javax.annotation.Nonnull + private byte[] signature; + + public VerifyPayload() {} + + public VerifyPayload data(@javax.annotation.Nonnull byte[] data) { + this.data = data; + return this; + } + + /** + * The data to be verified. Encoded in base64. + * + * @return data + */ + @javax.annotation.Nonnull + public byte[] getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull byte[] data) { + this.data = data; + } + + public VerifyPayload signature(@javax.annotation.Nonnull byte[] signature) { + this.signature = signature; + return this; + } + + /** + * The signature of the data. Encoded in base64. + * + * @return signature + */ + @javax.annotation.Nonnull + public byte[] getSignature() { + return signature; + } + + public void setSignature(@javax.annotation.Nonnull byte[] signature) { + this.signature = signature; + } + + /** + * 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 VerifyPayload instance itself + */ + public VerifyPayload 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; + } + VerifyPayload verifyPayload = (VerifyPayload) o; + return Arrays.equals(this.data, verifyPayload.data) + && Arrays.equals(this.signature, verifyPayload.signature) + && Objects.equals(this.additionalProperties, verifyPayload.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + Arrays.hashCode(data), Arrays.hashCode(signature), additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VerifyPayload {\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" signature: ").append(toIndentedString(signature)).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) { + return o == null ? "null" : 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("data", "signature")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("data", "signature")); + } + + /** + * 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 VerifyPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!VerifyPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in VerifyPayload is not found in the empty JSON string", + VerifyPayload.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : VerifyPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!VerifyPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'VerifyPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(VerifyPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, VerifyPayload 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public VerifyPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VerifyPayload instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of VerifyPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of VerifyPayload + * @throws IOException if the JSON string is invalid with respect to VerifyPayload + */ + public static VerifyPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, VerifyPayload.class); + } + + /** + * Convert an instance of VerifyPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Version.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Version.java new file mode 100644 index 00000000..a0495082 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/Version.java @@ -0,0 +1,600 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** Version */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class Version { + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nonnull + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_DESTROY_DATE = "destroyDate"; + + @SerializedName(SERIALIZED_NAME_DESTROY_DATE) + @javax.annotation.Nullable private OffsetDateTime destroyDate; + + public static final String SERIALIZED_NAME_DISABLED = "disabled"; + + @SerializedName(SERIALIZED_NAME_DISABLED) + @javax.annotation.Nonnull + private Boolean disabled = false; + + public static final String SERIALIZED_NAME_KEY_ID = "keyId"; + + @SerializedName(SERIALIZED_NAME_KEY_ID) + @javax.annotation.Nonnull + private UUID keyId; + + public static final String SERIALIZED_NAME_KEY_RING_ID = "keyRingId"; + + @SerializedName(SERIALIZED_NAME_KEY_RING_ID) + @javax.annotation.Nonnull + private UUID keyRingId; + + public static final String SERIALIZED_NAME_NUMBER = "number"; + + @SerializedName(SERIALIZED_NAME_NUMBER) + @javax.annotation.Nonnull + private Long number; + + public static final String SERIALIZED_NAME_PUBLIC_KEY = "publicKey"; + + @SerializedName(SERIALIZED_NAME_PUBLIC_KEY) + @javax.annotation.Nullable private String publicKey; + + /** The current state of the key. */ + @JsonAdapter(StateEnum.Adapter.class) + public enum StateEnum { + ACTIVE("active"), + + CREATING("creating"), + + KEY_MATERIAL_INVALID("key_material_invalid"), + + KEY_MATERIAL_UNAVAILABLE("key_material_unavailable"), + + DISABLED("disabled"), + + DESTROYED("destroyed"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StateEnum fromValue(String value) { + for (StateEnum b : StateEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StateEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StateEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StateEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StateEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nonnull + private StateEnum state; + + public Version() {} + + public Version createdAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The date and time the creation of the key was triggered. + * + * @return createdAt + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public Version destroyDate(@javax.annotation.Nullable OffsetDateTime destroyDate) { + this.destroyDate = destroyDate; + return this; + } + + /** + * The scheduled date when a version's key material will be erased completely from the + * backend + * + * @return destroyDate + */ + @javax.annotation.Nullable public OffsetDateTime getDestroyDate() { + return destroyDate; + } + + public void setDestroyDate(@javax.annotation.Nullable OffsetDateTime destroyDate) { + this.destroyDate = destroyDate; + } + + public Version disabled(@javax.annotation.Nonnull Boolean disabled) { + this.disabled = disabled; + return this; + } + + /** + * States whether versions is enabled or disabled. + * + * @return disabled + */ + @javax.annotation.Nonnull + public Boolean getDisabled() { + return disabled; + } + + public void setDisabled(@javax.annotation.Nonnull Boolean disabled) { + this.disabled = disabled; + } + + public Version keyId(@javax.annotation.Nonnull UUID keyId) { + this.keyId = keyId; + return this; + } + + /** + * The unique id of the key this version is assigned to. + * + * @return keyId + */ + @javax.annotation.Nonnull + public UUID getKeyId() { + return keyId; + } + + public void setKeyId(@javax.annotation.Nonnull UUID keyId) { + this.keyId = keyId; + } + + public Version keyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + return this; + } + + /** + * The unique id of the key ring the key of this version is assigned to. + * + * @return keyRingId + */ + @javax.annotation.Nonnull + public UUID getKeyRingId() { + return keyRingId; + } + + public void setKeyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + } + + public Version number(@javax.annotation.Nonnull Long number) { + this.number = number; + return this; + } + + /** + * A sequential number which identifies the key versions. + * + * @return number + */ + @javax.annotation.Nonnull + public Long getNumber() { + return number; + } + + public void setNumber(@javax.annotation.Nonnull Long number) { + this.number = number; + } + + public Version publicKey(@javax.annotation.Nullable String publicKey) { + this.publicKey = publicKey; + return this; + } + + /** + * The public key of the key version. Only present in asymmetric keys. + * + * @return publicKey + */ + @javax.annotation.Nullable public String getPublicKey() { + return publicKey; + } + + public void setPublicKey(@javax.annotation.Nullable String publicKey) { + this.publicKey = publicKey; + } + + public Version state(@javax.annotation.Nonnull StateEnum state) { + this.state = state; + return this; + } + + /** + * The current state of the key. + * + * @return state + */ + @javax.annotation.Nonnull + public StateEnum getState() { + return state; + } + + public void setState(@javax.annotation.Nonnull StateEnum 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 Version instance itself + */ + public Version 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; + } + Version version = (Version) o; + return Objects.equals(this.createdAt, version.createdAt) + && Objects.equals(this.destroyDate, version.destroyDate) + && Objects.equals(this.disabled, version.disabled) + && Objects.equals(this.keyId, version.keyId) + && Objects.equals(this.keyRingId, version.keyRingId) + && Objects.equals(this.number, version.number) + && Objects.equals(this.publicKey, version.publicKey) + && Objects.equals(this.state, version.state) + && Objects.equals(this.additionalProperties, version.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + createdAt, + destroyDate, + disabled, + keyId, + keyRingId, + number, + publicKey, + state, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Version {\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" destroyDate: ").append(toIndentedString(destroyDate)).append("\n"); + sb.append(" disabled: ").append(toIndentedString(disabled)).append("\n"); + sb.append(" keyId: ").append(toIndentedString(keyId)).append("\n"); + sb.append(" keyRingId: ").append(toIndentedString(keyRingId)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" publicKey: ").append(toIndentedString(publicKey)).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) { + return o == null ? "null" : 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", + "destroyDate", + "disabled", + "keyId", + "keyRingId", + "number", + "publicKey", + "state")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList( + "createdAt", "disabled", "keyId", "keyRingId", "number", "state")); + } + + /** + * 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 Version + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Version.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in Version is not found in the empty JSON string", + Version.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Version.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("keyId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keyId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("keyId").toString())); + } + if (!jsonObj.get("keyRingId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keyRingId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("keyRingId").toString())); + } + if ((jsonObj.get("publicKey") != null && !jsonObj.get("publicKey").isJsonNull()) + && !jsonObj.get("publicKey").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `publicKey` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("publicKey").toString())); + } + if (!jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + // validate the required field `state` + StateEnum.validateJsonElement(jsonObj.get("state")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Version.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Version' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Version.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Version 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Version read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Version instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of Version given an JSON string + * + * @param jsonString JSON string + * @return An instance of Version + * @throws IOException if the JSON string is invalid with respect to Version + */ + public static Version fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Version.class); + } + + /** + * Convert an instance of Version to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VersionList.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VersionList.java new file mode 100644 index 00000000..32480472 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/VersionList.java @@ -0,0 +1,321 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** VersionList */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class VersionList { + public static final String SERIALIZED_NAME_VERSIONS = "versions"; + + @SerializedName(SERIALIZED_NAME_VERSIONS) + @javax.annotation.Nonnull + private List versions = new ArrayList<>(); + + public VersionList() {} + + public VersionList versions(@javax.annotation.Nonnull List versions) { + this.versions = versions; + return this; + } + + public VersionList addVersionsItem(Version versionsItem) { + if (this.versions == null) { + this.versions = new ArrayList<>(); + } + this.versions.add(versionsItem); + return this; + } + + /** + * Get versions + * + * @return versions + */ + @javax.annotation.Nonnull + public List getVersions() { + return versions; + } + + public void setVersions(@javax.annotation.Nonnull List versions) { + this.versions = versions; + } + + /** + * 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 VersionList instance itself + */ + public VersionList 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; + } + VersionList versionList = (VersionList) o; + return Objects.equals(this.versions, versionList.versions) + && Objects.equals(this.additionalProperties, versionList.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(versions, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class VersionList {\n"); + sb.append(" versions: ").append(toIndentedString(versions)).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) { + return o == null ? "null" : 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("versions")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("versions")); + } + + /** + * 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 VersionList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!VersionList.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in VersionList is not found in the empty JSON string", + VersionList.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : VersionList.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("versions") != null) { + if (!jsonObj.get("versions").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `versions` to be an array in the JSON string but got `%s`", + jsonObj.get("versions").toString())); + } + JsonArray jsonArrayversions = jsonObj.getAsJsonArray("versions"); + // validate the required field `versions` (array) + for (int i = 0; i < jsonArrayversions.size(); i++) { + Version.validateJsonElement(jsonArrayversions.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!VersionList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'VersionList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(VersionList.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, VersionList 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public VersionList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + VersionList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of VersionList given an JSON string + * + * @param jsonString JSON string + * @return An instance of VersionList + * @throws IOException if the JSON string is invalid with respect to VersionList + */ + public static VersionList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, VersionList.class); + } + + /** + * Convert an instance of VersionList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingAlgorithm.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingAlgorithm.java new file mode 100644 index 00000000..d6bb7010 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingAlgorithm.java @@ -0,0 +1,85 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The wrapping algorithm used to wrap the key to import. */ +@JsonAdapter(WrappingAlgorithm.Adapter.class) +public enum WrappingAlgorithm { + RSA_2048_OAEP_SHA256("rsa_2048_oaep_sha256"), + + RSA_3072_OAEP_SHA256("rsa_3072_oaep_sha256"), + + RSA_4096_OAEP_SHA256("rsa_4096_oaep_sha256"), + + RSA_4096_OAEP_SHA512("rsa_4096_oaep_sha512"), + + RSA_2048_OAEP_SHA256_AES_256_KEY_WRAP("rsa_2048_oaep_sha256_aes_256_key_wrap"), + + RSA_3072_OAEP_SHA256_AES_256_KEY_WRAP("rsa_3072_oaep_sha256_aes_256_key_wrap"), + + RSA_4096_OAEP_SHA256_AES_256_KEY_WRAP("rsa_4096_oaep_sha256_aes_256_key_wrap"), + + RSA_4096_OAEP_SHA512_AES_256_KEY_WRAP("rsa_4096_oaep_sha512_aes_256_key_wrap"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + WrappingAlgorithm(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static WrappingAlgorithm fromValue(String value) { + for (WrappingAlgorithm b : WrappingAlgorithm.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final WrappingAlgorithm enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public WrappingAlgorithm read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return WrappingAlgorithm.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + WrappingAlgorithm.fromValue(value); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKey.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKey.java new file mode 100644 index 00000000..39bd0bd8 --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKey.java @@ -0,0 +1,747 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** WrappingKey */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class WrappingKey { + public static final String SERIALIZED_NAME_ACCESS_SCOPE = "access_scope"; + + @SerializedName(SERIALIZED_NAME_ACCESS_SCOPE) + @javax.annotation.Nonnull + private AccessScope accessScope = AccessScope.PUBLIC; + + public static final String SERIALIZED_NAME_ALGORITHM = "algorithm"; + + @SerializedName(SERIALIZED_NAME_ALGORITHM) + @javax.annotation.Nonnull + private WrappingAlgorithm algorithm; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + @javax.annotation.Nonnull + 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_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nonnull + private String displayName; + + public static final String SERIALIZED_NAME_EXPIRES_AT = "expiresAt"; + + @SerializedName(SERIALIZED_NAME_EXPIRES_AT) + @javax.annotation.Nonnull + private OffsetDateTime expiresAt; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_KEY_RING_ID = "keyRingId"; + + @SerializedName(SERIALIZED_NAME_KEY_RING_ID) + @javax.annotation.Nonnull + private UUID keyRingId; + + public static final String SERIALIZED_NAME_PROTECTION = "protection"; + + @SerializedName(SERIALIZED_NAME_PROTECTION) + @javax.annotation.Nonnull + private String protection; + + public static final String SERIALIZED_NAME_PUBLIC_KEY = "publicKey"; + + @SerializedName(SERIALIZED_NAME_PUBLIC_KEY) + @javax.annotation.Nullable private String publicKey; + + public static final String SERIALIZED_NAME_PURPOSE = "purpose"; + + @SerializedName(SERIALIZED_NAME_PURPOSE) + @javax.annotation.Nonnull + private WrappingPurpose purpose; + + /** The current state of the wrapping key. */ + @JsonAdapter(StateEnum.Adapter.class) + public enum StateEnum { + ACTIVE("active"), + + CREATING("creating"), + + EXPIRED("expired"), + + DELETED("deleted"), + + KEY_MATERIAL_UNAVAILABLE("key_material_unavailable"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StateEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StateEnum fromValue(String value) { + for (StateEnum b : StateEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StateEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StateEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StateEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StateEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATE = "state"; + + @SerializedName(SERIALIZED_NAME_STATE) + @javax.annotation.Nonnull + private StateEnum state; + + public WrappingKey() {} + + public WrappingKey(String publicKey) { + this(); + this.publicKey = publicKey; + } + + public WrappingKey accessScope(@javax.annotation.Nonnull AccessScope accessScope) { + this.accessScope = accessScope; + return this; + } + + /** + * Get accessScope + * + * @return accessScope + */ + @javax.annotation.Nonnull + public AccessScope getAccessScope() { + return accessScope; + } + + public void setAccessScope(@javax.annotation.Nonnull AccessScope accessScope) { + this.accessScope = accessScope; + } + + public WrappingKey algorithm(@javax.annotation.Nonnull WrappingAlgorithm algorithm) { + this.algorithm = algorithm; + return this; + } + + /** + * Get algorithm + * + * @return algorithm + */ + @javax.annotation.Nonnull + public WrappingAlgorithm getAlgorithm() { + return algorithm; + } + + public void setAlgorithm(@javax.annotation.Nonnull WrappingAlgorithm algorithm) { + this.algorithm = algorithm; + } + + public WrappingKey createdAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * The date and time the creation of the wrapping key was triggered. + * + * @return createdAt + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(@javax.annotation.Nonnull OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public WrappingKey description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * A user chosen description to distinguish multiple wrapping keys. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public WrappingKey displayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + return this; + } + + /** + * The display name to distinguish multiple wrapping keys. + * + * @return displayName + */ + @javax.annotation.Nonnull + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nonnull String displayName) { + this.displayName = displayName; + } + + public WrappingKey expiresAt(@javax.annotation.Nonnull OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + return this; + } + + /** + * The date and time the wrapping key will expire. + * + * @return expiresAt + */ + @javax.annotation.Nonnull + public OffsetDateTime getExpiresAt() { + return expiresAt; + } + + public void setExpiresAt(@javax.annotation.Nonnull OffsetDateTime expiresAt) { + this.expiresAt = expiresAt; + } + + public WrappingKey id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * A auto generated unique id which identifies the wrapping keys. + * + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + public WrappingKey keyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + return this; + } + + /** + * The unique id of the key ring this wrapping key is assigned to. + * + * @return keyRingId + */ + @javax.annotation.Nonnull + public UUID getKeyRingId() { + return keyRingId; + } + + public void setKeyRingId(@javax.annotation.Nonnull UUID keyRingId) { + this.keyRingId = keyRingId; + } + + public WrappingKey protection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + return this; + } + + /** + * The underlying system that is responsible for protecting the key material. Possible values + * are \"software\" or \"hsm\" + * + * @return protection + */ + @javax.annotation.Nonnull + public String getProtection() { + return protection; + } + + public void setProtection(@javax.annotation.Nonnull String protection) { + this.protection = protection; + } + + /** + * The public key of the wrapping key. + * + * @return publicKey + */ + @javax.annotation.Nullable public String getPublicKey() { + return publicKey; + } + + public WrappingKey purpose(@javax.annotation.Nonnull WrappingPurpose purpose) { + this.purpose = purpose; + return this; + } + + /** + * Get purpose + * + * @return purpose + */ + @javax.annotation.Nonnull + public WrappingPurpose getPurpose() { + return purpose; + } + + public void setPurpose(@javax.annotation.Nonnull WrappingPurpose purpose) { + this.purpose = purpose; + } + + public WrappingKey state(@javax.annotation.Nonnull StateEnum state) { + this.state = state; + return this; + } + + /** + * The current state of the wrapping key. + * + * @return state + */ + @javax.annotation.Nonnull + public StateEnum getState() { + return state; + } + + public void setState(@javax.annotation.Nonnull StateEnum 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 WrappingKey instance itself + */ + public WrappingKey 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; + } + WrappingKey wrappingKey = (WrappingKey) o; + return Objects.equals(this.accessScope, wrappingKey.accessScope) + && Objects.equals(this.algorithm, wrappingKey.algorithm) + && Objects.equals(this.createdAt, wrappingKey.createdAt) + && Objects.equals(this.description, wrappingKey.description) + && Objects.equals(this.displayName, wrappingKey.displayName) + && Objects.equals(this.expiresAt, wrappingKey.expiresAt) + && Objects.equals(this.id, wrappingKey.id) + && Objects.equals(this.keyRingId, wrappingKey.keyRingId) + && Objects.equals(this.protection, wrappingKey.protection) + && Objects.equals(this.publicKey, wrappingKey.publicKey) + && Objects.equals(this.purpose, wrappingKey.purpose) + && Objects.equals(this.state, wrappingKey.state) + && Objects.equals(this.additionalProperties, wrappingKey.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash( + accessScope, + algorithm, + createdAt, + description, + displayName, + expiresAt, + id, + keyRingId, + protection, + publicKey, + purpose, + state, + additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WrappingKey {\n"); + sb.append(" accessScope: ").append(toIndentedString(accessScope)).append("\n"); + sb.append(" algorithm: ").append(toIndentedString(algorithm)).append("\n"); + sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" expiresAt: ").append(toIndentedString(expiresAt)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" keyRingId: ").append(toIndentedString(keyRingId)).append("\n"); + sb.append(" protection: ").append(toIndentedString(protection)).append("\n"); + sb.append(" publicKey: ").append(toIndentedString(publicKey)).append("\n"); + sb.append(" purpose: ").append(toIndentedString(purpose)).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) { + return o == null ? "null" : 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( + "access_scope", + "algorithm", + "createdAt", + "description", + "displayName", + "expiresAt", + "id", + "keyRingId", + "protection", + "publicKey", + "purpose", + "state")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = + new HashSet( + Arrays.asList( + "access_scope", + "algorithm", + "createdAt", + "displayName", + "expiresAt", + "id", + "keyRingId", + "protection", + "purpose", + "state")); + } + + /** + * 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 WrappingKey + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WrappingKey.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in WrappingKey is not found in the empty JSON string", + WrappingKey.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WrappingKey.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `access_scope` + AccessScope.validateJsonElement(jsonObj.get("access_scope")); + // validate the required field `algorithm` + WrappingAlgorithm.validateJsonElement(jsonObj.get("algorithm")); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if (!jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if (!jsonObj.get("keyRingId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `keyRingId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("keyRingId").toString())); + } + if (!jsonObj.get("protection").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `protection` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("protection").toString())); + } + if ((jsonObj.get("publicKey") != null && !jsonObj.get("publicKey").isJsonNull()) + && !jsonObj.get("publicKey").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `publicKey` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("publicKey").toString())); + } + // validate the required field `purpose` + WrappingPurpose.validateJsonElement(jsonObj.get("purpose")); + if (!jsonObj.get("state").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `state` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("state").toString())); + } + // validate the required field `state` + StateEnum.validateJsonElement(jsonObj.get("state")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WrappingKey.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WrappingKey' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(WrappingKey.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, WrappingKey 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WrappingKey read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WrappingKey instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of WrappingKey given an JSON string + * + * @param jsonString JSON string + * @return An instance of WrappingKey + * @throws IOException if the JSON string is invalid with respect to WrappingKey + */ + public static WrappingKey fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WrappingKey.class); + } + + /** + * Convert an instance of WrappingKey to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKeyList.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKeyList.java new file mode 100644 index 00000000..da6c51cc --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingKeyList.java @@ -0,0 +1,322 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import cloud.stackit.sdk.kms.v1api.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonNull; +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; + +/** WrappingKeyList */ +@javax.annotation.Generated(value = "JavaGenerator", comments = "Generator version: 7.26.0") +public class WrappingKeyList { + public static final String SERIALIZED_NAME_WRAPPING_KEYS = "wrappingKeys"; + + @SerializedName(SERIALIZED_NAME_WRAPPING_KEYS) + @javax.annotation.Nonnull + private List wrappingKeys = new ArrayList<>(); + + public WrappingKeyList() {} + + public WrappingKeyList wrappingKeys(@javax.annotation.Nonnull List wrappingKeys) { + this.wrappingKeys = wrappingKeys; + return this; + } + + public WrappingKeyList addWrappingKeysItem(WrappingKey wrappingKeysItem) { + if (this.wrappingKeys == null) { + this.wrappingKeys = new ArrayList<>(); + } + this.wrappingKeys.add(wrappingKeysItem); + return this; + } + + /** + * Get wrappingKeys + * + * @return wrappingKeys + */ + @javax.annotation.Nonnull + public List getWrappingKeys() { + return wrappingKeys; + } + + public void setWrappingKeys(@javax.annotation.Nonnull List wrappingKeys) { + this.wrappingKeys = wrappingKeys; + } + + /** + * 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 WrappingKeyList instance itself + */ + public WrappingKeyList 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; + } + WrappingKeyList wrappingKeyList = (WrappingKeyList) o; + return Objects.equals(this.wrappingKeys, wrappingKeyList.wrappingKeys) + && Objects.equals(this.additionalProperties, wrappingKeyList.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(wrappingKeys, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WrappingKeyList {\n"); + sb.append(" wrappingKeys: ").append(toIndentedString(wrappingKeys)).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) { + return o == null ? "null" : 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("wrappingKeys")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("wrappingKeys")); + } + + /** + * 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 WrappingKeyList + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WrappingKeyList.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field(s) %s in WrappingKeyList is not found in the empty JSON string", + WrappingKeyList.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : WrappingKeyList.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The required field `%s` is not found in the JSON string: %s", + requiredField, + jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("wrappingKeys") != null) { + if (!jsonObj.get("wrappingKeys").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "Expected the field `wrappingKeys` to be an array in the JSON string but got `%s`", + jsonObj.get("wrappingKeys").toString())); + } + JsonArray jsonArraywrappingKeys = jsonObj.getAsJsonArray("wrappingKeys"); + // validate the required field `wrappingKeys` (array) + for (int i = 0; i < jsonArraywrappingKeys.size(); i++) { + WrappingKey.validateJsonElement(jsonArraywrappingKeys.get(i)); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WrappingKeyList.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WrappingKeyList' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(WrappingKeyList.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, WrappingKeyList 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.isJsonNull()) { + obj.add(entry.getKey(), JsonNull.INSTANCE); + } else if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WrappingKeyList read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WrappingKeyList instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + java.util.Locale.ROOT, + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of WrappingKeyList given an JSON string + * + * @param jsonString JSON string + * @return An instance of WrappingKeyList + * @throws IOException if the JSON string is invalid with respect to WrappingKeyList + */ + public static WrappingKeyList fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WrappingKeyList.class); + } + + /** + * Convert an instance of WrappingKeyList to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingPurpose.java b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingPurpose.java new file mode 100644 index 00000000..778c41bf --- /dev/null +++ b/services/kms/src/main/java/cloud/stackit/sdk/kms/v1api/model/WrappingPurpose.java @@ -0,0 +1,73 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.model; + +import com.google.gson.JsonElement; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +/** The wrapping purpose for the wrapping key. */ +@JsonAdapter(WrappingPurpose.Adapter.class) +public enum WrappingPurpose { + WRAP_SYMMETRIC_KEY("wrap_symmetric_key"), + + WRAP_ASYMMETRIC_KEY("wrap_asymmetric_key"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + WrappingPurpose(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static WrappingPurpose fromValue(String value) { + for (WrappingPurpose b : WrappingPurpose.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final WrappingPurpose enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public WrappingPurpose read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return WrappingPurpose.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + WrappingPurpose.fromValue(value); + } +} diff --git a/services/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/DefaultApiTest.java b/services/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/DefaultApiTest.java new file mode 100644 index 00000000..2585a423 --- /dev/null +++ b/services/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/DefaultApiTest.java @@ -0,0 +1,66 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api; + +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/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/KmsApiTest.java b/services/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/KmsApiTest.java new file mode 100644 index 00000000..cd84e816 --- /dev/null +++ b/services/kms/src/test/java/cloud/stackit/sdk/kms/v1api/api/KmsApiTest.java @@ -0,0 +1,67 @@ +/* + * STACKIT Key Management Service API + * This API provides endpoints for managing keys and key rings. + * + * The version of the OpenAPI document: 1.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.kms.v1api.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 KmsApi */ +public class KmsApiTest { + @Test + public void TestCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + OkHttpClient httpClient = new OkHttpClient(); + KmsApi api = new KmsApi(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 + KmsApi api = new KmsApi(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()); + } +}