diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..12b52c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Compiled class file +*.class + +# Log file +*.log + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* + +# Gradle +.gradle +**/build/ +!**/src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath \ No newline at end of file diff --git a/services/resourcemanager/README.md b/services/resourcemanager/README.md new file mode 100644 index 0000000..c706ceb --- /dev/null +++ b/services/resourcemanager/README.md @@ -0,0 +1,133 @@ +# stackit-sdk-resourcemanager + +Resource Manager API + +- API version: 2.0 + +API v2 to manage resource containers - organizations, folders, projects incl. labels + +### Resource Management +STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, +folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. + +### Organizations +STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. +- Organizations are always the root node in resource hierarchy and do not have a parent + +### Projects +STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. +- Projects are optional, but mandatory for cloud-resource usage +- A project can be created having either an organization, or a folder as parent +- A project must not have a project as parent +- Project names under the same parent must not be unique +- Root organization cannot be changed + +### Label +STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. +- Policy-based, immutable labels may exists + +For more information, please visit [https://support.stackit.cloud/servicedesk](https://support.stackit.cloud/servicedesk) + +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. + + +## Requirements + +Building the API client library requires: +1. Java 1.8+ + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +./gradlew publishToMavenLocal +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +# TODO: follow up story +# ./gradlew publishToMavenCentral +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit + stackit-sdk-resourcemanager + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() // Needed if the 'stackit-sdk-resourcemanager' jar has been published to maven central. + mavenLocal() // Needed if the 'stackit-sdk-resourcemanager' jar has been published to the local maven repo. + } + + dependencies { + implementation "cloud.stackit:stackit-sdk-resourcemanager:" + } +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +- `target/stackit-sdk-resourcemanager-.jar` +- `target/lib/*.jar` + +## Getting Started + +Please follow the [installation](#installation) instruction and execute the following Java code: + +```java + +import cloud.stackit.sdk.resourcemanager.*; +import cloud.stackit.sdk.resourcemanager.auth.*; +import cloud.stackit.sdk.resourcemanager.model.*; +import cloud.stackit.sdk.resourcemanager.api.DefaultApi; + +public class DefaultApiExample { + + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("https://resource-manager.api.stackit.cloud"); + + DefaultApi apiInstance = new DefaultApi(defaultClient); + CreateFolderPayload createFolderPayload = new CreateFolderPayload(); // CreateFolderPayload | + try { + FolderResponse result = apiInstance.createFolder(createFolderPayload); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling DefaultApi#createFolder"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} + +``` + +## 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/resourcemanager/build.gradle b/services/resourcemanager/build.gradle new file mode 100644 index 0000000..be9bafd --- /dev/null +++ b/services/resourcemanager/build.gradle @@ -0,0 +1,166 @@ +apply plugin: 'idea' +apply plugin: 'eclipse' +apply plugin: 'java' +apply plugin: 'com.diffplug.spotless' + +group = 'cloud.stackit' +version = '2.0' + +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.3.+' + classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1' + classpath 'com.diffplug.spotless:spotless-plugin-gradle:6.11.0' + } +} + +repositories { + mavenCentral() +} +sourceSets { + main.java.srcDirs = ['src/main/java'] +} + +if(hasProperty('target') && target == 'android') { + + apply plugin: 'com.android.library' + apply plugin: 'com.github.dcendents.android-maven' + + android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + defaultConfig { + minSdkVersion 14 + targetSdkVersion 25 + } + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + // Rename the aar correctly + libraryVariants.all { variant -> + variant.outputs.each { output -> + def outputFile = output.outputFile + if (outputFile != null && outputFile.name.endsWith('.aar')) { + def fileName = "${project.name}-${variant.baseName}-${version}.aar" + output.outputFile = new File(outputFile.parent, fileName) + } + } + } + + dependencies { + provided "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + } + } + + afterEvaluate { + android.libraryVariants.all { variant -> + def task = project.tasks.create "jar${variant.name.capitalize()}", Jar + task.description = "Create jar artifact for ${variant.name}" + task.dependsOn variant.javaCompile + task.from variant.javaCompile.destinationDirectory + task.destinationDirectory = project.file("${project.buildDir}/outputs/jar") + task.archiveFileName = "${project.name}-${variant.baseName}-${version}.jar" + artifacts.add('archives', task) + } + } + + task sourcesJar(type: Jar) { + from android.sourceSets.main.java.srcDirs + classifier = 'sources' + } + + artifacts { + archives sourcesJar + } + +} else { + + apply plugin: 'java' + apply plugin: 'maven-publish' + + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + + publishing { + publications { + maven(MavenPublication) { + artifactId = 'stackit-sdk-resourcemanager' + from components.java + } + } + } + + task execute(type:JavaExec) { + main = System.getProperty('mainClass') + classpath = sourceSets.main.runtimeClasspath + } +} + +ext { + jakarta_annotation_version = "1.3.5" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.9.0' + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' + implementation 'org.openapitools:jackson-databind-nullable:0.2.6' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} + +javadoc { + options.tags = [ "http.response.details:a:Http Response Details" ] +} + +// Use spotless plugin to automatically format code, remove unused import, etc +// To apply changes directly to the file, run `gradlew spotlessApply` +// Ref: https://github.com/diffplug/spotless/tree/main/plugin-gradle +spotless { + // comment out below to run spotless as part of the `check` task + enforceCheck false + + format 'misc', { + // define the files (e.g. '*.gradle', '*.md') to apply `misc` to + target '.gitignore' + + // define the steps to apply to those files + trimTrailingWhitespace() + indentWithSpaces() // Takes an integer argument if you don't like 4 + endWithNewline() + } + java { + // don't need to set target, it is inferred from java + + // apply a specific flavor of google-java-format + googleJavaFormat('1.8').aosp().reflowLongStrings() + + removeUnusedImports() + importOrder() + } +} + +test { + // Enable JUnit 5 (Gradle 4.6+). + useJUnitPlatform() + + // Always run tests, even when nothing changed. + dependsOn 'cleanTest' + + // Show test results. + testLogging { + events "passed", "skipped", "failed" + } + +} diff --git a/services/resourcemanager/gradle.properties b/services/resourcemanager/gradle.properties new file mode 100644 index 0000000..a340857 --- /dev/null +++ b/services/resourcemanager/gradle.properties @@ -0,0 +1,6 @@ +# This file is automatically generated by OpenAPI Generator (https://github.com/openAPITools/openapi-generator). +# To include other gradle properties as part of the code generation process, please use the `gradleProperties` option. +# +# Gradle properties reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_configuration_properties +# For example, uncomment below to build for Android +#target = android diff --git a/services/resourcemanager/gradle/wrapper/gradle-wrapper.properties b/services/resourcemanager/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..b82aa23 --- /dev/null +++ b/services/resourcemanager/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/services/resourcemanager/gradlew b/services/resourcemanager/gradlew new file mode 100644 index 0000000..9d0ce63 --- /dev/null +++ b/services/resourcemanager/gradlew @@ -0,0 +1,249 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while +APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path +[ -h "$app_path" ] +do +ls=$( ls -ld "$app_path" ) +link=${ls#*' -> '} +case $link in #( +/*) app_path=$link ;; #( +*) app_path=$APP_HOME$link ;; +esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { +echo "$*" +} >&2 + +die () { +echo +echo "$*" +echo +exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( +CYGWIN* ) cygwin=true ;; #( +Darwin* ) darwin=true ;; #( +MSYS* | MINGW* ) msys=true ;; #( +NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then +if [ -x "$JAVA_HOME/jre/sh/java" ] ; then +# IBM's JDK on AIX uses strange locations for the executables +JAVACMD=$JAVA_HOME/jre/sh/java +else +JAVACMD=$JAVA_HOME/bin/java +fi +if [ ! -x "$JAVACMD" ] ; then +die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +else +JAVACMD=java +if ! command -v java >/dev/null 2>&1 +then +die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then +case $MAX_FD in #( +max*) +# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +MAX_FD=$( ulimit -H -n ) || +warn "Could not query maximum file descriptor limit" +esac +case $MAX_FD in #( +'' | soft) :;; #( +*) +# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. +# shellcheck disable=SC2039,SC3045 +ulimit -n "$MAX_FD" || +warn "Could not set maximum file descriptor limit to $MAX_FD" +esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then +APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) +CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + +JAVACMD=$( cygpath --unix "$JAVACMD" ) + +# Now convert the arguments - kludge to limit ourselves to /bin/sh +for arg do +if +case $arg in #( +-*) false ;; # don't mess with options #( +/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath +[ -e "$t" ] ;; #( +*) false ;; +esac +then +arg=$( cygpath --path --ignore --mixed "$arg" ) +fi +# Roll the args list around exactly as many times as the number of +# args, so each arg winds up back in the position where it started, but +# possibly modified. +# +# NB: a `for` loop captures its iteration list before it begins, so +# changing the positional parameters here affects neither the number of +# iterations, nor the values presented in `arg`. +shift # remove old arg +set -- "$@" "$arg" # push replacement arg +done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ +"-Dorg.gradle.appname=$APP_BASE_NAME" \ +-classpath "$CLASSPATH" \ +org.gradle.wrapper.GradleWrapperMain \ +"$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then +die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( +printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | +xargs -n1 | +sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | +tr '\n' ' ' +)" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/services/resourcemanager/gradlew.bat b/services/resourcemanager/gradlew.bat new file mode 100644 index 0000000..25da30d --- /dev/null +++ b/services/resourcemanager/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/services/resourcemanager/settings.gradle b/services/resourcemanager/settings.gradle new file mode 100644 index 0000000..9136f3d --- /dev/null +++ b/services/resourcemanager/settings.gradle @@ -0,0 +1 @@ +rootProject.name = "stackit-sdk-resourcemanager" \ No newline at end of file diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiCallback.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiCallback.java new file mode 100644 index 0000000..b4a77bf --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiCallback.java @@ -0,0 +1,62 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * 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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiClient.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiClient.java new file mode 100644 index 0000000..b320769 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiClient.java @@ -0,0 +1,1593 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +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; + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +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.security.cert.X509Certificate; +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.function.Supplier; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import cloud.stackit.sdk.resourcemanager.auth.Authentication; +import cloud.stackit.sdk.resourcemanager.auth.HttpBasicAuth; +import cloud.stackit.sdk.resourcemanager.auth.HttpBearerAuth; +import cloud.stackit.sdk.resourcemanager.auth.ApiKeyAuth; + +/** + *

ApiClient class.

+ */ +public class ApiClient { + + protected String basePath = "https://resource-manager.api.stackit.cloud"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "https://resource-manager.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 Map authentications; + + protected DateFormat dateFormat; + protected DateFormat datetimeFormat; + protected boolean lenientDatetimeFormat; + protected int dateLength; + + protected InputStream sslCaCert; + protected boolean verifyingSsl; + protected KeyManager[] keyManagers; + + protected OkHttpClient httpClient; + protected JSON json; + + protected HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + 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/resourcemanager"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g https://resource-manager.api.stackit.cloud + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

+ * + * @return an array of {@link javax.net.ssl.KeyManager} objects + */ + public KeyManager[] getKeyManagers() { + return keyManagers; + } + + /** + * Configure client keys to use for authorization in an SSL session. + * Use null to reset to default. + * + * @param managers The KeyManagers to use + * @return ApiClient + */ + public ApiClient setKeyManagers(KeyManager[] managers) { + this.keyManagers = managers; + applySslSettings(); + return this; + } + + /** + *

Getter for the field dateFormat.

+ * + * @return a {@link java.text.DateFormat} object + */ + public DateFormat getDateFormat() { + return dateFormat; + } + + /** + *

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link cloud.stackit.sdk.resourcemanager.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.resourcemanager.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.resourcemanager.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.resourcemanager.ApiClient} object + */ + public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) { + JSON.setLocalDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link cloud.stackit.sdk.resourcemanager.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param sessionToken Session Token + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String sessionToken, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * The path of temporary folder used to store downloaded files from endpoints + * with file response. The default value is null, i.e. using + * the system's default temporary folder. + * + * @see createTempFile + * @return Temporary folder path + */ + public String getTempFolderPath() { + return tempFolderPath; + } + + /** + * Set the temporary folder path (for downloading files) + * + * @param tempFolderPath Temporary folder path + * @return ApiClient + */ + public ApiClient setTempFolderPath(String tempFolderPath) { + this.tempFolderPath = tempFolderPath; + return this; + } + + /** + * Get connection timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getConnectTimeout() { + return httpClient.connectTimeoutMillis(); + } + + /** + * Sets the connect timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param connectionTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setConnectTimeout(int connectionTimeout) { + httpClient = httpClient.newBuilder().connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get read timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getReadTimeout() { + return httpClient.readTimeoutMillis(); + } + + /** + * Sets the read timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param readTimeout read timeout in milliseconds + * @return Api client + */ + public ApiClient setReadTimeout(int readTimeout) { + httpClient = httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + /** + * Get write timeout (in milliseconds). + * + * @return Timeout in milliseconds + */ + public int getWriteTimeout() { + return httpClient.writeTimeoutMillis(); + } + + /** + * Sets the write timeout (in milliseconds). + * A value of 0 means no timeout, otherwise values must be between 1 and + * {@link java.lang.Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build(); + return this; + } + + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if (param instanceof Date || param instanceof OffsetDateTime || param instanceof LocalDate) { + //Serialize to json string and remove the " enclosing characters + String jsonStr = JSON.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(o); + } + return b.toString(); + } else { + return String.valueOf(param); + } + } + + /** + * Formats the specified query parameter to a list containing a single {@code Pair} object. + * + * Note that {@code value} must not be a collection. + * + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list containing a single {@code Pair} object. + */ + public List parameterToPair(String name, Object value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value instanceof Collection) { + return params; + } + + params.add(new Pair(name, parameterToString(value))); + return params; + } + + /** + * Formats the specified collection query parameters to a list of {@code Pair} objects. + * + * Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map )) { + return params; + } + + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder() ; + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. + * e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceFirst("^.*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. + * JSON MIME examples: + * application/json + * application/json; charset=UTF8 + * APPLICATION/JSON + * application/vnd.company+json + * "* / *" is also default to JSON + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: + * if JSON exists in the given array, use it; + * otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, + * null will be returned (not to set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: + * if JSON exists in the given array, use it; + * otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, + * returns null. If it matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and + * the Content-Type response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws cloud.stackit.sdk.resourcemanager.ApiException If fail to deserialize response body, i.e. cannot read response body + * or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + ResponseBody respBody = response.body(); + if (respBody == null) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + try { + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody.byteStream(), returnType); + } else if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Expecting string, return the raw response body. + return (T) respBodyString; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + response.body().string()); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Serialize the given Java object into request body according to the object's + * class and the request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws cloud.stackit.sdk.resourcemanager.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.resourcemanager.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.resourcemanager.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.resourcemanager.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.resourcemanager.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.resourcemanager.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.resourcemanager.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); + + // update parameters with authentication settings + updateParamsForAuth(authNames, updatedQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws cloud.stackit.sdk.resourcemanager.ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + protected void addPartToMultiPartBuilder(MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for + * async requests. + */ + protected Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse.newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of + * verifyingSsl and sslCaCert. + */ + protected void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = new TrustManager[]{ + new X509TrustManager() { + @Override + public void checkClientTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public void checkServerTrusted(java.security.cert.X509Certificate[] chain, String authType) throws CertificateException { + } + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[]{}; + } + } + }; + hostnameVerifier = new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException("expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = httpClient.newBuilder() + .sslSocketFactory(sslContext.getSocketFactory(), (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws cloud.stackit.sdk.resourcemanager.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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiException.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiException.java new file mode 100644 index 0000000..b959584 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiException.java @@ -0,0 +1,167 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.Map; +import java.util.List; + + +/** + *

ApiException class.

+ */ +@SuppressWarnings("serial") +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ApiException extends Exception { + private static final long serialVersionUID = 1L; + + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

+ */ + public ApiException() {} + + /** + *

Constructor for ApiException.

+ * + * @param throwable a {@link java.lang.Throwable} object + */ + public ApiException(Throwable throwable) { + super(throwable); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + */ + public ApiException(String message) { + super(message); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param message the error message + * @param throwable a {@link java.lang.Throwable} object + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + */ + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, Map> responseHeaders, String responseBody) { + this("Response Code: " + code + " Response Body: " + responseBody, (Throwable) null, code, responseHeaders, responseBody); + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message a {@link java.lang.String} object + */ + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + /** + *

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiResponse.java new file mode 100644 index 0000000..7429627 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ApiResponse.java @@ -0,0 +1,76 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private 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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Configuration.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Configuration.java new file mode 100644 index 0000000..8794718 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Configuration.java @@ -0,0 +1,63 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.Objects; +import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class Configuration { + public static final String VERSION = "2.0"; + + private static final AtomicReference defaultApiClient = new AtomicReference<>(); + private static volatile Supplier apiClientFactory = ApiClient::new; + + /** + * Get the default API client, which would be used when creating API instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + ApiClient client = defaultApiClient.get(); + if (client == null) { + client = defaultApiClient.updateAndGet(val -> { + if (val != null) { // changed by another thread + return val; + } + return apiClientFactory.get(); + }); + } + return client; + } + + /** + * Set the default API client, which would be used when creating API instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient.set(apiClient); + } + + /** + * set the callback used to create new ApiClient objects + */ + public static void setApiClientFactory(Supplier factory) { + apiClientFactory = Objects.requireNonNull(factory); + } + + private Configuration() { + } +} \ No newline at end of file diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/GzipRequestInterceptor.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/GzipRequestInterceptor.java new file mode 100644 index 0000000..fbeaf5d --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/GzipRequestInterceptor.java @@ -0,0 +1,85 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * 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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java new file mode 100644 index 0000000..4604632 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/JSON.java @@ -0,0 +1,444 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +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 com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + +import okio.ByteString; + +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.nio.charset.StandardCharsets; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +/* + * A JSON utility class + * + * NOTE: in the future, this class may be converted to static, which may break + * backward-compatibility + */ +public class JSON { + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + return builder; + } + + private static String getDiscriminatorValue(JsonElement readElement, String discriminatorField) { + JsonElement element = readElement.getAsJsonObject().get(discriminatorField); + if (null == element) { + throw new IllegalArgumentException("missing discriminator field: <" + discriminatorField + ">"); + } + return element.getAsString(); + } + + /** + * Returns the Java class that implements the OpenAPI schema for the specified discriminator value. + * + * @param classByDiscriminatorValue The map of discriminator values to Java classes. + * @param discriminatorValue The value of the OpenAPI discriminator in the input data. + * @return The Java class that implements the OpenAPI schema + */ + private static Class getClassByDiscriminator(Map classByDiscriminatorValue, String discriminatorValue) { + Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + static { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter); + gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.CreateFolderPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.CreateProjectPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ErrorResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.FolderResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.GetFolderDetailsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.GetProjectResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ListFoldersResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ListFoldersResponseItemsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ListOrganizationsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ListOrganizationsResponseItemsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ListProjectsResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.Member.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.OrganizationResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.Parent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.ParentListInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.PartialUpdateFolderPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.PartialUpdateOrganizationPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.PartialUpdateProjectPayload.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new cloud.stackit.sdk.resourcemanager.model.Project.CustomTypeAdapterFactory()); + gson = gsonBuilder.create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public static Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + */ + public static void setGson(Gson gson) { + JSON.gson = gson; + } + + public static void setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public static String serialize(Object obj) { + return gson.toJson(obj); + } + + /** + * Deserialize the given JSON string to Java object. + * + * @param Type + * @param body The JSON string + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(String body, Type returnType) { + try { + if (isLenientOnJson) { + JsonReader jsonReader = new JsonReader(new StringReader(body)); + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(body, returnType); + } + } catch (JsonParseException e) { + // Fallback processing when failed to parse JSON form response body: + // return the response body string directly for the String return type; + if (returnType.equals(String.class)) { + return (T) body; + } else { + throw (e); + } + } + } + + /** + * Deserialize the given JSON InputStream to a Java object. + * + * @param Type + * @param inputStream The JSON InputStream + * @param returnType The type to deserialize into + * @return The deserialized Java object + */ + @SuppressWarnings("unchecked") + public static T deserialize(InputStream inputStream, Type returnType) throws IOException { + try (InputStreamReader reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8)) { + if (isLenientOnJson) { + // see https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/stream/JsonReader.html#setLenient(boolean) + JsonReader jsonReader = new JsonReader(reader); + jsonReader.setLenient(true); + return gson.fromJson(jsonReader, returnType); + } else { + return gson.fromJson(reader, returnType); + } + } + } + + /** + * Gson TypeAdapter for Byte Array type + */ + public static class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public static class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public static void setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + } + + public static void setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + } + + /** + * Gson TypeAdapter for java.sql.Date type + * If the dateFormat is null, a simple "yyyy-MM-dd" format will be used + * (more efficient than SimpleDateFormat). + */ + public static class SqlDateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public SqlDateTypeAdapter() {} + + public SqlDateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, java.sql.Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = date.toString(); + } + out.value(value); + } + } + + @Override + public java.sql.Date read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return new java.sql.Date(dateFormat.parse(date).getTime()); + } + return new java.sql.Date(ISO8601Utils.parse(date, new ParsePosition(0)).getTime()); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } + } + + /** + * Gson TypeAdapter for java.util.Date type + * If the dateFormat is null, ISO8601Utils will be used. + */ + public static class DateTypeAdapter extends TypeAdapter { + + private DateFormat dateFormat; + + public DateTypeAdapter() {} + + public DateTypeAdapter(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + public void setFormat(DateFormat dateFormat) { + this.dateFormat = dateFormat; + } + + @Override + public void write(JsonWriter out, Date date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + String value; + if (dateFormat != null) { + value = dateFormat.format(date); + } else { + value = ISO8601Utils.format(date, true); + } + out.value(value); + } + } + + @Override + public Date read(JsonReader in) throws IOException { + try { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + try { + if (dateFormat != null) { + return dateFormat.parse(date); + } + return ISO8601Utils.parse(date, new ParsePosition(0)); + } catch (ParseException e) { + throw new JsonParseException(e); + } + } + } catch (IllegalArgumentException e) { + throw new JsonParseException(e); + } + } + } + + public static void setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + } + + public static void setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Pair.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Pair.java new file mode 100644 index 0000000..8975646 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/Pair.java @@ -0,0 +1,57 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + return true; + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressRequestBody.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressRequestBody.java new file mode 100644 index 0000000..c420844 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressRequestBody.java @@ -0,0 +1,73 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressResponseBody.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressResponseBody.java new file mode 100644 index 0000000..1e80dbd --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ProgressResponseBody.java @@ -0,0 +1,70 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerConfiguration.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerConfiguration.java new file mode 100644 index 0000000..d660748 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerConfiguration.java @@ -0,0 +1,72 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.Map; + +/** + * Representing a Server configuration. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerVariable.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerVariable.java new file mode 100644 index 0000000..b6dac84 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/StringUtil.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/StringUtil.java new file mode 100644 index 0000000..a997c08 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/StringUtil.java @@ -0,0 +1,83 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager; + +import java.util.Collection; +import java.util.Iterator; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.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/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/api/DefaultApi.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/api/DefaultApi.java new file mode 100644 index 0000000..1ad7720 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/api/DefaultApi.java @@ -0,0 +1,2389 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.api; + +import cloud.stackit.sdk.resourcemanager.ApiCallback; +import cloud.stackit.sdk.resourcemanager.ApiClient; +import cloud.stackit.sdk.resourcemanager.ApiException; +import cloud.stackit.sdk.resourcemanager.ApiResponse; +import cloud.stackit.sdk.resourcemanager.Configuration; +import cloud.stackit.sdk.resourcemanager.Pair; +import cloud.stackit.sdk.resourcemanager.ProgressRequestBody; +import cloud.stackit.sdk.resourcemanager.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import java.math.BigDecimal; +import cloud.stackit.sdk.resourcemanager.model.CreateFolderPayload; +import cloud.stackit.sdk.resourcemanager.model.CreateProjectPayload; +import cloud.stackit.sdk.resourcemanager.model.ErrorResponse; +import cloud.stackit.sdk.resourcemanager.model.FolderResponse; +import cloud.stackit.sdk.resourcemanager.model.GetFolderDetailsResponse; +import cloud.stackit.sdk.resourcemanager.model.GetProjectResponse; +import cloud.stackit.sdk.resourcemanager.model.ListFoldersResponse; +import cloud.stackit.sdk.resourcemanager.model.ListOrganizationsResponse; +import cloud.stackit.sdk.resourcemanager.model.ListProjectsResponse; +import java.time.OffsetDateTime; +import cloud.stackit.sdk.resourcemanager.model.OrganizationResponse; +import cloud.stackit.sdk.resourcemanager.model.PartialUpdateFolderPayload; +import cloud.stackit.sdk.resourcemanager.model.PartialUpdateOrganizationPayload; +import cloud.stackit.sdk.resourcemanager.model.PartialUpdateProjectPayload; +import cloud.stackit.sdk.resourcemanager.model.Project; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class DefaultApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public DefaultApi() { + this(Configuration.getDefaultApiClient()); + } + + public DefaultApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + 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 createFolder + * @param createFolderPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call createFolderCall(@javax.annotation.Nullable CreateFolderPayload createFolderPayload, 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 = createFolderPayload; + + // create path and map variables + String localVarPath = "/v2/folders"; + + 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 createFolderValidateBeforeCall(@javax.annotation.Nullable CreateFolderPayload createFolderPayload, final ApiCallback _callback) throws ApiException { + return createFolderCall(createFolderPayload, _callback); + + } + + /** + * Create Folder + * Create a new folder. + * @param createFolderPayload (optional) + * @return FolderResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public FolderResponse createFolder(@javax.annotation.Nullable CreateFolderPayload createFolderPayload) throws ApiException { + ApiResponse localVarResp = createFolderWithHttpInfo(createFolderPayload); + return localVarResp.getData(); + } + + /** + * Create Folder + * Create a new folder. + * @param createFolderPayload (optional) + * @return ApiResponse<FolderResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public ApiResponse createFolderWithHttpInfo(@javax.annotation.Nullable CreateFolderPayload createFolderPayload) throws ApiException { + okhttp3.Call localVarCall = createFolderValidateBeforeCall(createFolderPayload, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Folder (asynchronously) + * Create a new folder. + * @param createFolderPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call createFolderAsync(@javax.annotation.Nullable CreateFolderPayload createFolderPayload, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createFolderValidateBeforeCall(createFolderPayload, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for createProject + * @param createProjectPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Project created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call createProjectCall(@javax.annotation.Nullable CreateProjectPayload createProjectPayload, 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 = createProjectPayload; + + // create path and map variables + String localVarPath = "/v2/projects"; + + 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 createProjectValidateBeforeCall(@javax.annotation.Nullable CreateProjectPayload createProjectPayload, final ApiCallback _callback) throws ApiException { + return createProjectCall(createProjectPayload, _callback); + + } + + /** + * Create Project + * Create a new project. - The request is synchronous, but the workflow-based creation is asynchronous. - Lifecycle state remains in CREATING, until workflow completes + * @param createProjectPayload (optional) + * @return Project + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Project created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public Project createProject(@javax.annotation.Nullable CreateProjectPayload createProjectPayload) throws ApiException { + ApiResponse localVarResp = createProjectWithHttpInfo(createProjectPayload); + return localVarResp.getData(); + } + + /** + * Create Project + * Create a new project. - The request is synchronous, but the workflow-based creation is asynchronous. - Lifecycle state remains in CREATING, until workflow completes + * @param createProjectPayload (optional) + * @return ApiResponse<Project> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Project created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public ApiResponse createProjectWithHttpInfo(@javax.annotation.Nullable CreateProjectPayload createProjectPayload) throws ApiException { + okhttp3.Call localVarCall = createProjectValidateBeforeCall(createProjectPayload, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Project (asynchronously) + * Create a new project. - The request is synchronous, but the workflow-based creation is asynchronous. - Lifecycle state remains in CREATING, until workflow completes + * @param createProjectPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
201 Project created -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call createProjectAsync(@javax.annotation.Nullable CreateProjectPayload createProjectPayload, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createProjectValidateBeforeCall(createProjectPayload, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteFolder + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param force If true, all nested, empty folders are deleted recursively - if no project is attached! (optional, default to false) + * @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 process triggered -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call deleteFolderCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean force, 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 = "/v2/folders/{containerId}" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (force != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("force", force)); + } + + 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 deleteFolderValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean force, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling deleteFolder(Async)"); + } + + return deleteFolderCall(containerId, force, _callback); + + } + + /** + * Delete Folder + * Delete a folder and its metadata. - Folder must not be parent of any other container - A force flag may be set, deleting all underlying folders recursively - if no project is attached! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param force If true, all nested, empty folders are deleted recursively - if no project is attached! (optional, default to false) + * @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 process triggered -
404 Not Found -
409 Conflict -
+ */ + public void deleteFolder(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean force) throws ApiException { + deleteFolderWithHttpInfo(containerId, force); + } + + /** + * Delete Folder + * Delete a folder and its metadata. - Folder must not be parent of any other container - A force flag may be set, deleting all underlying folders recursively - if no project is attached! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param force If true, all nested, empty folders are deleted recursively - if no project is attached! (optional, default to false) + * @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 process triggered -
404 Not Found -
409 Conflict -
+ */ + public ApiResponse deleteFolderWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean force) throws ApiException { + okhttp3.Call localVarCall = deleteFolderValidateBeforeCall(containerId, force, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Folder (asynchronously) + * Delete a folder and its metadata. - Folder must not be parent of any other container - A force flag may be set, deleting all underlying folders recursively - if no project is attached! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param force If true, all nested, empty folders are deleted recursively - if no project is attached! (optional, default to false) + * @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 process triggered -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call deleteFolderAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean force, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteFolderValidateBeforeCall(containerId, force, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for deleteFolderLabels + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteFolderLabelsCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, 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 = "/v2/folders/{containerId}/labels" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (keys != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "keys", keys)); + } + + 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 deleteFolderLabelsValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling deleteFolderLabels(Async)"); + } + + return deleteFolderLabelsCall(containerId, keys, _callback); + + } + + /** + * Delete Folder Labels + * Deletes all folder labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public void deleteFolderLabels(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + deleteFolderLabelsWithHttpInfo(containerId, keys); + } + + /** + * Delete Folder Labels + * Deletes all folder labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public ApiResponse deleteFolderLabelsWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + okhttp3.Call localVarCall = deleteFolderLabelsValidateBeforeCall(containerId, keys, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Folder Labels (asynchronously) + * Deletes all folder labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteFolderLabelsAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteFolderLabelsValidateBeforeCall(containerId, keys, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for deleteOrganizationLabels + * @param containerId Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteOrganizationLabelsCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, 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 = "/v2/organizations/{containerId}/labels" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (keys != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "keys", keys)); + } + + 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 deleteOrganizationLabelsValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling deleteOrganizationLabels(Async)"); + } + + return deleteOrganizationLabelsCall(containerId, keys, _callback); + + } + + /** + * Delete Organization Labels + * Deletes all organization labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public void deleteOrganizationLabels(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + deleteOrganizationLabelsWithHttpInfo(containerId, keys); + } + + /** + * Delete Organization Labels + * Deletes all organization labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public ApiResponse deleteOrganizationLabelsWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + okhttp3.Call localVarCall = deleteOrganizationLabelsValidateBeforeCall(containerId, keys, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Organization Labels (asynchronously) + * Deletes all organization labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteOrganizationLabelsAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteOrganizationLabelsValidateBeforeCall(containerId, keys, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for deleteProject + * @param id Project identifier - containerId as well as UUID identifier is supported. (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 process triggered -
409 Conflict -
+ */ + public okhttp3.Call deleteProjectCall(@javax.annotation.Nonnull String id, 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 = "/v2/projects/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.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 deleteProjectValidateBeforeCall(@javax.annotation.Nonnull String id, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling deleteProject(Async)"); + } + + return deleteProjectCall(id, _callback); + + } + + /** + * Delete Project + * Triggers the deletion of a project. - The request is synchronous, but the workflow-based deletion is asynchronous - Lifecycle state remains in DELETING, until workflow completes + * @param id Project identifier - containerId as well as UUID identifier is supported. (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 process triggered -
409 Conflict -
+ */ + public void deleteProject(@javax.annotation.Nonnull String id) throws ApiException { + deleteProjectWithHttpInfo(id); + } + + /** + * Delete Project + * Triggers the deletion of a project. - The request is synchronous, but the workflow-based deletion is asynchronous - Lifecycle state remains in DELETING, until workflow completes + * @param id Project identifier - containerId as well as UUID identifier is supported. (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 process triggered -
409 Conflict -
+ */ + public ApiResponse deleteProjectWithHttpInfo(@javax.annotation.Nonnull String id) throws ApiException { + okhttp3.Call localVarCall = deleteProjectValidateBeforeCall(id, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Project (asynchronously) + * Triggers the deletion of a project. - The request is synchronous, but the workflow-based deletion is asynchronous - Lifecycle state remains in DELETING, until workflow completes + * @param id Project identifier - containerId as well as UUID identifier is supported. (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 process triggered -
409 Conflict -
+ */ + public okhttp3.Call deleteProjectAsync(@javax.annotation.Nonnull String id, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteProjectValidateBeforeCall(id, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for deleteProjectLabels + * @param containerId Project identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteProjectLabelsCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, 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 = "/v2/projects/{containerId}/labels" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (keys != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "keys", keys)); + } + + 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 deleteProjectLabelsValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling deleteProjectLabels(Async)"); + } + + return deleteProjectLabelsCall(containerId, keys, _callback); + + } + + /** + * Delete Project Labels + * Deletes all project labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Project identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public void deleteProjectLabels(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + deleteProjectLabelsWithHttpInfo(containerId, keys); + } + + /** + * Delete Project Labels + * Deletes all project labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Project identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @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 Labels removed -
409 Conflict -
+ */ + public ApiResponse deleteProjectLabelsWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys) throws ApiException { + okhttp3.Call localVarCall = deleteProjectLabelsValidateBeforeCall(containerId, keys, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Project Labels (asynchronously) + * Deletes all project labels by given keys. - Specific labels may be deleted by key(s) - If no key is specified, all labels will be deleted! + * @param containerId Project identifier - containerId as well as UUID identifier is supported. (required) + * @param keys Label name. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
202 Labels removed -
409 Conflict -
+ */ + public okhttp3.Call deleteProjectLabelsAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable List keys, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteProjectLabelsValidateBeforeCall(containerId, keys, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for getFolderDetails + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getFolderDetailsCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean includeParents, 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 = "/v2/folders/{containerId}" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (includeParents != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("includeParents", includeParents)); + } + + 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 getFolderDetailsValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean includeParents, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling getFolderDetails(Async)"); + } + + return getFolderDetailsCall(containerId, includeParents, _callback); + + } + + /** + * Get Folder Details + * Returns all metadata for a specific folder. + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @return GetFolderDetailsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public GetFolderDetailsResponse getFolderDetails(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean includeParents) throws ApiException { + ApiResponse localVarResp = getFolderDetailsWithHttpInfo(containerId, includeParents); + return localVarResp.getData(); + } + + /** + * Get Folder Details + * Returns all metadata for a specific folder. + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @return ApiResponse<GetFolderDetailsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public ApiResponse getFolderDetailsWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean includeParents) throws ApiException { + okhttp3.Call localVarCall = getFolderDetailsValidateBeforeCall(containerId, includeParents, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Folder Details (asynchronously) + * Returns all metadata for a specific folder. + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getFolderDetailsAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable Boolean includeParents, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getFolderDetailsValidateBeforeCall(containerId, includeParents, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getOrganization + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
+ */ + public okhttp3.Call getOrganizationCall(@javax.annotation.Nonnull String id, 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 = "/v2/organizations/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.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 getOrganizationValidateBeforeCall(@javax.annotation.Nonnull String id, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling getOrganization(Async)"); + } + + return getOrganizationCall(id, _callback); + + } + + /** + * Get Organization Details + * Returns the organization and its metadata. + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @return OrganizationResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
+ */ + public OrganizationResponse getOrganization(@javax.annotation.Nonnull String id) throws ApiException { + ApiResponse localVarResp = getOrganizationWithHttpInfo(id); + return localVarResp.getData(); + } + + /** + * Get Organization Details + * Returns the organization and its metadata. + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @return ApiResponse<OrganizationResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
+ */ + public ApiResponse getOrganizationWithHttpInfo(@javax.annotation.Nonnull String id) throws ApiException { + okhttp3.Call localVarCall = getOrganizationValidateBeforeCall(id, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Organization Details (asynchronously) + * Returns the organization and its metadata. + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
+ */ + public okhttp3.Call getOrganizationAsync(@javax.annotation.Nonnull String id, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getOrganizationValidateBeforeCall(id, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for getProject + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getProjectCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable Boolean includeParents, 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 = "/v2/projects/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (includeParents != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("includeParents", includeParents)); + } + + 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 getProjectValidateBeforeCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable Boolean includeParents, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling getProject(Async)"); + } + + return getProjectCall(id, includeParents, _callback); + + } + + /** + * Get Project Details + * Returns the project and its metadata. + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @return GetProjectResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public GetProjectResponse getProject(@javax.annotation.Nonnull String id, @javax.annotation.Nullable Boolean includeParents) throws ApiException { + ApiResponse localVarResp = getProjectWithHttpInfo(id, includeParents); + return localVarResp.getData(); + } + + /** + * Get Project Details + * Returns the project and its metadata. + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @return ApiResponse<GetProjectResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public ApiResponse getProjectWithHttpInfo(@javax.annotation.Nonnull String id, @javax.annotation.Nullable Boolean includeParents) throws ApiException { + okhttp3.Call localVarCall = getProjectValidateBeforeCall(id, includeParents, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Project Details (asynchronously) + * Returns the project and its metadata. + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param includeParents (optional, default to false) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getProjectAsync(@javax.annotation.Nonnull String id, @javax.annotation.Nullable Boolean includeParents, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getProjectValidateBeforeCall(id, includeParents, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listFolders + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call listFoldersCall(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, 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 = "/v2/folders"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (containerParentId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("containerParentId", containerParentId)); + } + + if (containerIds != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "containerIds", containerIds)); + } + + if (member != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("member", member)); + } + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (offset != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset)); + } + + if (creationTimeStart != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("creation-time-start", creationTimeStart)); + } + + 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 listFoldersValidateBeforeCall(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + return listFoldersCall(containerParentId, containerIds, member, limit, offset, creationTimeStart, _callback); + + } + + /** + * Get All Folders + * Returns all folders and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of <br /> Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ListFoldersResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public ListFoldersResponse listFolders(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + ApiResponse localVarResp = listFoldersWithHttpInfo(containerParentId, containerIds, member, limit, offset, creationTimeStart); + return localVarResp.getData(); + } + + /** + * Get All Folders + * Returns all folders and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of <br /> Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ApiResponse<ListFoldersResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public ApiResponse listFoldersWithHttpInfo(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + okhttp3.Call localVarCall = listFoldersValidateBeforeCall(containerParentId, containerIds, member, limit, offset, creationTimeStart, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get All Folders (asynchronously) + * Returns all folders and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of <br /> Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
409 Conflict -
+ */ + public okhttp3.Call listFoldersAsync(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listFoldersValidateBeforeCall(containerParentId, containerIds, member, limit, offset, creationTimeStart, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listOrganizations + * @param containerIds Organization identifiers - containerId as well as UUID identifier is supported. A combination of both is not allowed. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public okhttp3.Call listOrganizationsCall(@javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, 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 = "/v2/organizations"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (containerIds != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "containerIds", containerIds)); + } + + if (member != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("member", member)); + } + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (offset != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset)); + } + + if (creationTimeStart != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("creation-time-start", creationTimeStart)); + } + + 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 listOrganizationsValidateBeforeCall(@javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + return listOrganizationsCall(containerIds, member, limit, offset, creationTimeStart, _callback); + + } + + /** + * Get All Organizations + * Returns all organizations and their metadata. - If no containerIds are specified, all organizations are returned, if permitted - ContainerIds may be set to filter - Member may be set to filter - If member and containerIds are given, both are used for filtering + * @param containerIds Organization identifiers - containerId as well as UUID identifier is supported. A combination of both is not allowed. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ListOrganizationsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public ListOrganizationsResponse listOrganizations(@javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + ApiResponse localVarResp = listOrganizationsWithHttpInfo(containerIds, member, limit, offset, creationTimeStart); + return localVarResp.getData(); + } + + /** + * Get All Organizations + * Returns all organizations and their metadata. - If no containerIds are specified, all organizations are returned, if permitted - ContainerIds may be set to filter - Member may be set to filter - If member and containerIds are given, both are used for filtering + * @param containerIds Organization identifiers - containerId as well as UUID identifier is supported. A combination of both is not allowed. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ApiResponse<ListOrganizationsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public ApiResponse listOrganizationsWithHttpInfo(@javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + okhttp3.Call localVarCall = listOrganizationsValidateBeforeCall(containerIds, member, limit, offset, creationTimeStart, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get All Organizations (asynchronously) + * Returns all organizations and their metadata. - If no containerIds are specified, all organizations are returned, if permitted - ContainerIds may be set to filter - Member may be set to filter - If member and containerIds are given, both are used for filtering + * @param containerIds Organization identifiers - containerId as well as UUID identifier is supported. A combination of both is not allowed. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public okhttp3.Call listOrganizationsAsync(@javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listOrganizationsValidateBeforeCall(containerIds, member, limit, offset, creationTimeStart, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listProjects + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public okhttp3.Call listProjectsCall(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable OffsetDateTime creationTimeStart, 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 = "/v2/projects"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (containerParentId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("containerParentId", containerParentId)); + } + + if (containerIds != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "containerIds", containerIds)); + } + + if (member != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("member", member)); + } + + if (offset != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("offset", offset)); + } + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + if (creationTimeStart != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("creation-time-start", creationTimeStart)); + } + + 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 listProjectsValidateBeforeCall(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + return listProjectsCall(containerParentId, containerIds, member, offset, limit, creationTimeStart, _callback); + + } + + /** + * Get All Projects + * Returns all projects and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ListProjectsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public ListProjectsResponse listProjects(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + ApiResponse localVarResp = listProjectsWithHttpInfo(containerParentId, containerIds, member, offset, limit, creationTimeStart); + return localVarResp.getData(); + } + + /** + * Get All Projects + * Returns all projects and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @return ApiResponse<ListProjectsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public ApiResponse listProjectsWithHttpInfo(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable OffsetDateTime creationTimeStart) throws ApiException { + okhttp3.Call localVarCall = listProjectsValidateBeforeCall(containerParentId, containerIds, member, offset, limit, creationTimeStart, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get All Projects (asynchronously) + * Returns all projects and their metadata that: - Are children of the specific containerParentId - Match the given containerIds - User is member of Filter: - Either containerParentId OR containerIds OR member must be passed - If containerId and containerParentId are given, both are used for filtering - containers must point to the same parent - If member and containerParentId are given, both are used for filtering - If member is given, containers must not point to the same container parent + * @param containerParentId Identifier of the parent resource container - containerId as well as UUID identifier is supported. (optional) + * @param containerIds List of container identifiers - containerId as well as UUID identifier is supported. (optional) + * @param member E-Mail address of the user for whom the visible resource containers should be filtered. (optional) + * @param offset The offset of the first item in the collection to return. (optional, default to 0) + * @param limit The maximum number of projects to return in the response. If not present, an appropriate default will be used. If maximum is exceeded, maximum is used. (optional, default to 50) + * @param creationTimeStart A timestamp to specify the beginning of the creationTime from which entries should be returned. If not given, defaults to the beginning of time. (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
403 Forbidden -
+ */ + public okhttp3.Call listProjectsAsync(@javax.annotation.Nullable String containerParentId, @javax.annotation.Nullable List containerIds, @javax.annotation.Nullable String member, @javax.annotation.Nullable BigDecimal offset, @javax.annotation.Nullable BigDecimal limit, @javax.annotation.Nullable OffsetDateTime creationTimeStart, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listProjectsValidateBeforeCall(containerParentId, containerIds, member, offset, limit, creationTimeStart, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for partialUpdateFolder + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateFolderPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateFolderCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable PartialUpdateFolderPayload partialUpdateFolderPayload, 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 = partialUpdateFolderPayload; + + // create path and map variables + String localVarPath = "/v2/folders/{containerId}" + .replace("{" + "containerId" + "}", localVarApiClient.escapeString(containerId.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, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call partialUpdateFolderValidateBeforeCall(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable PartialUpdateFolderPayload partialUpdateFolderPayload, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'containerId' is set + if (containerId == null) { + throw new ApiException("Missing the required parameter 'containerId' when calling partialUpdateFolder(Async)"); + } + + return partialUpdateFolderCall(containerId, partialUpdateFolderPayload, _callback); + + } + + /** + * Update Folder + * Update the folder and its metadata. - Update folder name - Update folder labels - Update folder parent (folder or organization) + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateFolderPayload (optional) + * @return FolderResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public FolderResponse partialUpdateFolder(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable PartialUpdateFolderPayload partialUpdateFolderPayload) throws ApiException { + ApiResponse localVarResp = partialUpdateFolderWithHttpInfo(containerId, partialUpdateFolderPayload); + return localVarResp.getData(); + } + + /** + * Update Folder + * Update the folder and its metadata. - Update folder name - Update folder labels - Update folder parent (folder or organization) + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateFolderPayload (optional) + * @return ApiResponse<FolderResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public ApiResponse partialUpdateFolderWithHttpInfo(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable PartialUpdateFolderPayload partialUpdateFolderPayload) throws ApiException { + okhttp3.Call localVarCall = partialUpdateFolderValidateBeforeCall(containerId, partialUpdateFolderPayload, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Folder (asynchronously) + * Update the folder and its metadata. - Update folder name - Update folder labels - Update folder parent (folder or organization) + * @param containerId Folder identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateFolderPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateFolderAsync(@javax.annotation.Nonnull String containerId, @javax.annotation.Nullable PartialUpdateFolderPayload partialUpdateFolderPayload, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = partialUpdateFolderValidateBeforeCall(containerId, partialUpdateFolderPayload, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for partialUpdateOrganization + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateOrganizationPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateOrganizationCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateOrganizationPayload partialUpdateOrganizationPayload, 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 = partialUpdateOrganizationPayload; + + // create path and map variables + String localVarPath = "/v2/organizations/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.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, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call partialUpdateOrganizationValidateBeforeCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateOrganizationPayload partialUpdateOrganizationPayload, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling partialUpdateOrganization(Async)"); + } + + return partialUpdateOrganizationCall(id, partialUpdateOrganizationPayload, _callback); + + } + + /** + * Update Organization + * Update the organization and its metadata. - Update organization name - Update organization labels + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateOrganizationPayload (optional) + * @return OrganizationResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
409 Conflict -
+ */ + public OrganizationResponse partialUpdateOrganization(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateOrganizationPayload partialUpdateOrganizationPayload) throws ApiException { + ApiResponse localVarResp = partialUpdateOrganizationWithHttpInfo(id, partialUpdateOrganizationPayload); + return localVarResp.getData(); + } + + /** + * Update Organization + * Update the organization and its metadata. - Update organization name - Update organization labels + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateOrganizationPayload (optional) + * @return ApiResponse<OrganizationResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
409 Conflict -
+ */ + public ApiResponse partialUpdateOrganizationWithHttpInfo(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateOrganizationPayload partialUpdateOrganizationPayload) throws ApiException { + okhttp3.Call localVarCall = partialUpdateOrganizationValidateBeforeCall(id, partialUpdateOrganizationPayload, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Organization (asynchronously) + * Update the organization and its metadata. - Update organization name - Update organization labels + * @param id Organization identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateOrganizationPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateOrganizationAsync(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateOrganizationPayload partialUpdateOrganizationPayload, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = partialUpdateOrganizationValidateBeforeCall(id, partialUpdateOrganizationPayload, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for partialUpdateProject + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateProjectPayload (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateProjectCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateProjectPayload partialUpdateProjectPayload, 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 = partialUpdateProjectPayload; + + // create path and map variables + String localVarPath = "/v2/projects/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.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, "PATCH", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call partialUpdateProjectValidateBeforeCall(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateProjectPayload partialUpdateProjectPayload, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling partialUpdateProject(Async)"); + } + + return partialUpdateProjectCall(id, partialUpdateProjectPayload, _callback); + + } + + /** + * Update Project + * Update the project and its metadata. - Update project name - Update project labels - Update project parent (folder or organization) + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateProjectPayload (optional) + * @return Project + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public Project partialUpdateProject(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateProjectPayload partialUpdateProjectPayload) throws ApiException { + ApiResponse localVarResp = partialUpdateProjectWithHttpInfo(id, partialUpdateProjectPayload); + return localVarResp.getData(); + } + + /** + * Update Project + * Update the project and its metadata. - Update project name - Update project labels - Update project parent (folder or organization) + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateProjectPayload (optional) + * @return ApiResponse<Project> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public ApiResponse partialUpdateProjectWithHttpInfo(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateProjectPayload partialUpdateProjectPayload) throws ApiException { + okhttp3.Call localVarCall = partialUpdateProjectValidateBeforeCall(id, partialUpdateProjectPayload, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update Project (asynchronously) + * Update the project and its metadata. - Update project name - Update project labels - Update project parent (folder or organization) + * @param id Project identifier - containerId as well as UUID identifier is supported. (required) + * @param partialUpdateProjectPayload (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
403 Forbidden -
404 Not Found -
409 Conflict -
+ */ + public okhttp3.Call partialUpdateProjectAsync(@javax.annotation.Nonnull String id, @javax.annotation.Nullable PartialUpdateProjectPayload partialUpdateProjectPayload, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = partialUpdateProjectValidateBeforeCall(id, partialUpdateProjectPayload, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/ApiKeyAuth.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/ApiKeyAuth.java new file mode 100644 index 0000000..fac4dc7 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/ApiKeyAuth.java @@ -0,0 +1,80 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.auth; + +import cloud.stackit.sdk.resourcemanager.ApiException; +import cloud.stackit.sdk.resourcemanager.Pair; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ApiKeyAuth implements Authentication { + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/Authentication.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/Authentication.java new file mode 100644 index 0000000..2d27488 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/Authentication.java @@ -0,0 +1,37 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.auth; + +import cloud.stackit.sdk.resourcemanager.Pair; +import cloud.stackit.sdk.resourcemanager.ApiException; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public interface Authentication { + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBasicAuth.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBasicAuth.java new file mode 100644 index 0000000..3c44122 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBasicAuth.java @@ -0,0 +1,55 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.auth; + +import cloud.stackit.sdk.resourcemanager.Pair; +import cloud.stackit.sdk.resourcemanager.ApiException; + +import okhttp3.Credentials; + +import java.net.URI; +import java.util.Map; +import java.util.List; + +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBearerAuth.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBearerAuth.java new file mode 100644 index 0000000..92d33dd --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/auth/HttpBearerAuth.java @@ -0,0 +1,75 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.auth; + +import cloud.stackit.sdk.resourcemanager.ApiException; +import cloud.stackit.sdk.resourcemanager.Pair; + +import java.net.URI; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.function.Supplier; + +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class HttpBearerAuth implements Authentication { + private final String scheme; + private Supplier tokenSupplier; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return tokenSupplier.get(); + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.tokenSupplier = () -> bearerToken; + } + + /** + * Sets the supplier of tokens, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param tokenSupplier The supplier of bearer tokens to send in the Authorization header + */ + public void setBearerToken(Supplier tokenSupplier) { + this.tokenSupplier = tokenSupplier; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + String bearerToken = Optional.ofNullable(tokenSupplier).map(Supplier::get).orElse(null); + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/AbstractOpenApiSchema.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..a652f15 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/AbstractOpenApiSchema.java @@ -0,0 +1,146 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import cloud.stackit.sdk.resourcemanager.ApiException; +import java.util.Objects; +import java.lang.reflect.Type; +import java.util.Map; + +/** + * Abstract class for oneOf,anyOf schemas defined in OpenAPI spec + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + //@JsonValue + public Object getActualInstance() {return instance;} + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) {this.instance = instance;} + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema)object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) && + Objects.equals(this.isNullable, a.isNullable) && + Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } + + + +} diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateFolderPayload.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateFolderPayload.java new file mode 100644 index 0000000..9d3fc84 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateFolderPayload.java @@ -0,0 +1,328 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Member; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * CreateFolderPayload + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class CreateFolderPayload { + public static final String SERIALIZED_NAME_CONTAINER_PARENT_ID = "containerParentId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_PARENT_ID) + @javax.annotation.Nonnull + private String containerParentId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + @javax.annotation.Nullable + private Set members = new LinkedHashSet<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public CreateFolderPayload() { + } + + public CreateFolderPayload containerParentId(@javax.annotation.Nonnull String containerParentId) { + this.containerParentId = containerParentId; + return this; + } + + /** + * Identifier of the parent resource container - containerId as well as UUID identifier is supported. + * @return containerParentId + */ + @javax.annotation.Nonnull + public String getContainerParentId() { + return containerParentId; + } + + public void setContainerParentId(@javax.annotation.Nonnull String containerParentId) { + this.containerParentId = containerParentId; + } + + + public CreateFolderPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateFolderPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public CreateFolderPayload members(@javax.annotation.Nullable Set members) { + this.members = members; + return this; + } + + public CreateFolderPayload addMembersItem(Member membersItem) { + if (this.members == null) { + this.members = new LinkedHashSet<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * The initial members assigned to the project. At least one subject needs to be a user, and not a client or service account. + * @return members + */ + @javax.annotation.Nullable + public Set getMembers() { + return members; + } + + public void setMembers(@javax.annotation.Nullable Set members) { + this.members = members; + } + + + public CreateFolderPayload name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * The name of the folder matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateFolderPayload createFolderPayload = (CreateFolderPayload) o; + return Objects.equals(this.containerParentId, createFolderPayload.containerParentId) && + Objects.equals(this.labels, createFolderPayload.labels) && + Objects.equals(this.members, createFolderPayload.members) && + Objects.equals(this.name, createFolderPayload.name); + } + + @Override + public int hashCode() { + return Objects.hash(containerParentId, labels, members, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateFolderPayload {\n"); + sb.append(" containerParentId: ").append(toIndentedString(containerParentId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerParentId", "labels", "members", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerParentId", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateFolderPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateFolderPayload.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateFolderPayload is not found in the empty JSON string", CreateFolderPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateFolderPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateFolderPayload` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateFolderPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerParentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerParentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerParentId").toString())); + } + if (jsonObj.get("members") != null && !jsonObj.get("members").isJsonNull()) { + JsonArray jsonArraymembers = jsonObj.getAsJsonArray("members"); + if (jsonArraymembers != null) { + // ensure the json data is an array + if (!jsonObj.get("members").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); + } + + // validate the optional field `members` (array) + for (int i = 0; i < jsonArraymembers.size(); i++) { + Member.validateJsonElement(jsonArraymembers.get(i)); + }; + } + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateFolderPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateFolderPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateFolderPayload.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateFolderPayload value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateFolderPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateFolderPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateFolderPayload + * @throws IOException if the JSON string is invalid with respect to CreateFolderPayload + */ + public static CreateFolderPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateFolderPayload.class); + } + + /** + * Convert an instance of CreateFolderPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateProjectPayload.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateProjectPayload.java new file mode 100644 index 0000000..de0756b --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/CreateProjectPayload.java @@ -0,0 +1,324 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Member; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.LinkedHashSet; +import java.util.Map; +import java.util.Set; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * CreateProjectPayload + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class CreateProjectPayload { + public static final String SERIALIZED_NAME_CONTAINER_PARENT_ID = "containerParentId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_PARENT_ID) + @javax.annotation.Nonnull + private String containerParentId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_MEMBERS = "members"; + @SerializedName(SERIALIZED_NAME_MEMBERS) + @javax.annotation.Nonnull + private Set members = new LinkedHashSet<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public CreateProjectPayload() { + } + + public CreateProjectPayload containerParentId(@javax.annotation.Nonnull String containerParentId) { + this.containerParentId = containerParentId; + return this; + } + + /** + * Identifier of the parent resource container - containerId as well as UUID identifier is supported. + * @return containerParentId + */ + @javax.annotation.Nonnull + public String getContainerParentId() { + return containerParentId; + } + + public void setContainerParentId(@javax.annotation.Nonnull String containerParentId) { + this.containerParentId = containerParentId; + } + + + public CreateProjectPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateProjectPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public CreateProjectPayload members(@javax.annotation.Nonnull Set members) { + this.members = members; + return this; + } + + public CreateProjectPayload addMembersItem(Member membersItem) { + if (this.members == null) { + this.members = new LinkedHashSet<>(); + } + this.members.add(membersItem); + return this; + } + + /** + * The initial members assigned to the project. At least one subject needs to be a user, and not a client or service account. + * @return members + */ + @javax.annotation.Nonnull + public Set getMembers() { + return members; + } + + public void setMembers(@javax.annotation.Nonnull Set members) { + this.members = members; + } + + + public CreateProjectPayload name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Project name matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateProjectPayload createProjectPayload = (CreateProjectPayload) o; + return Objects.equals(this.containerParentId, createProjectPayload.containerParentId) && + Objects.equals(this.labels, createProjectPayload.labels) && + Objects.equals(this.members, createProjectPayload.members) && + Objects.equals(this.name, createProjectPayload.name); + } + + @Override + public int hashCode() { + return Objects.hash(containerParentId, labels, members, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateProjectPayload {\n"); + sb.append(" containerParentId: ").append(toIndentedString(containerParentId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" members: ").append(toIndentedString(members)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerParentId", "labels", "members", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerParentId", "members", "name")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateProjectPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateProjectPayload.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in CreateProjectPayload is not found in the empty JSON string", CreateProjectPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateProjectPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `CreateProjectPayload` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateProjectPayload.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerParentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerParentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerParentId").toString())); + } + // ensure the json data is an array + if (!jsonObj.get("members").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `members` to be an array in the JSON string but got `%s`", jsonObj.get("members").toString())); + } + + JsonArray jsonArraymembers = jsonObj.getAsJsonArray("members"); + // validate the required field `members` (array) + for (int i = 0; i < jsonArraymembers.size(); i++) { + Member.validateJsonElement(jsonArraymembers.get(i)); + }; + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateProjectPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateProjectPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateProjectPayload.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateProjectPayload value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateProjectPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateProjectPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateProjectPayload + * @throws IOException if the JSON string is invalid with respect to CreateProjectPayload + */ + public static CreateProjectPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateProjectPayload.class); + } + + /** + * Convert an instance of CreateProjectPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ErrorResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ErrorResponse.java new file mode 100644 index 0000000..bfda8bf --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ErrorResponse.java @@ -0,0 +1,324 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ErrorResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ErrorResponse { + public static final String SERIALIZED_NAME_ERROR = "error"; + @SerializedName(SERIALIZED_NAME_ERROR) + @javax.annotation.Nonnull + private String error; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nonnull + private String message; + + public static final String SERIALIZED_NAME_PATH = "path"; + @SerializedName(SERIALIZED_NAME_PATH) + @javax.annotation.Nonnull + private String path; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private BigDecimal status; + + public static final String SERIALIZED_NAME_TIME_STAMP = "timeStamp"; + @SerializedName(SERIALIZED_NAME_TIME_STAMP) + @javax.annotation.Nonnull + private OffsetDateTime timeStamp; + + public ErrorResponse() { + } + + public ErrorResponse error(@javax.annotation.Nonnull String error) { + this.error = error; + return this; + } + + /** + * The reason phrase of the status code. + * @return error + */ + @javax.annotation.Nonnull + public String getError() { + return error; + } + + public void setError(@javax.annotation.Nonnull String error) { + this.error = error; + } + + + public ErrorResponse message(@javax.annotation.Nonnull String message) { + this.message = message; + return this; + } + + /** + * Description of the error. + * @return message + */ + @javax.annotation.Nonnull + public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nonnull String message) { + this.message = message; + } + + + public ErrorResponse path(@javax.annotation.Nonnull String path) { + this.path = path; + return this; + } + + /** + * Path which was called. + * @return path + */ + @javax.annotation.Nonnull + public String getPath() { + return path; + } + + public void setPath(@javax.annotation.Nonnull String path) { + this.path = path; + } + + + public ErrorResponse status(@javax.annotation.Nonnull BigDecimal status) { + this.status = status; + return this; + } + + /** + * Http Status Code. + * @return status + */ + @javax.annotation.Nonnull + public BigDecimal getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull BigDecimal status) { + this.status = status; + } + + + public ErrorResponse timeStamp(@javax.annotation.Nonnull OffsetDateTime timeStamp) { + this.timeStamp = timeStamp; + return this; + } + + /** + * Timestamp at which the error occurred. + * @return timeStamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(@javax.annotation.Nonnull OffsetDateTime timeStamp) { + this.timeStamp = timeStamp; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.error, errorResponse.error) && + Objects.equals(this.message, errorResponse.message) && + Objects.equals(this.path, errorResponse.path) && + Objects.equals(this.status, errorResponse.status) && + Objects.equals(this.timeStamp, errorResponse.timeStamp); + } + + @Override + public int hashCode() { + return Objects.hash(error, message, path, status, timeStamp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\n"); + sb.append(" error: ").append(toIndentedString(error)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" path: ").append(toIndentedString(path)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" timeStamp: ").append(toIndentedString(timeStamp)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("error", "message", "path", "status", "timeStamp")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("error", "message", "path", "status", "timeStamp")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ErrorResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ErrorResponse is not found in the empty JSON string", ErrorResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ErrorResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ErrorResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("error").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString())); + } + if (!jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString())); + } + if (!jsonObj.get("path").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `path` to be a primitive type in the JSON string but got `%s`", jsonObj.get("path").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ErrorResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponse + * @throws IOException if the JSON string is invalid with respect to ErrorResponse + */ + public static ErrorResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponse.class); + } + + /** + * Convert an instance of ErrorResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/FolderResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/FolderResponse.java new file mode 100644 index 0000000..928355f --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/FolderResponse.java @@ -0,0 +1,389 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Parent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * FolderResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class FolderResponse { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_FOLDER_ID = "folderId"; + @SerializedName(SERIALIZED_NAME_FOLDER_ID) + @javax.annotation.Nonnull + private UUID folderId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private Parent parent; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public FolderResponse() { + } + + public FolderResponse containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique, user-friendly identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public FolderResponse creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the folder was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public FolderResponse folderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + return this; + } + + /** + * Globally unique folder identifier. + * @return folderId + */ + @javax.annotation.Nonnull + public UUID getFolderId() { + return folderId; + } + + public void setFolderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + } + + + public FolderResponse labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public FolderResponse putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public FolderResponse name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Folder name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public FolderResponse parent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + return this; + } + + /** + * Get parent + * @return parent + */ + @javax.annotation.Nonnull + public Parent getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + } + + + public FolderResponse updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the folder was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FolderResponse folderResponse = (FolderResponse) o; + return Objects.equals(this.containerId, folderResponse.containerId) && + Objects.equals(this.creationTime, folderResponse.creationTime) && + Objects.equals(this.folderId, folderResponse.folderId) && + Objects.equals(this.labels, folderResponse.labels) && + Objects.equals(this.name, folderResponse.name) && + Objects.equals(this.parent, folderResponse.parent) && + Objects.equals(this.updateTime, folderResponse.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, folderId, labels, name, parent, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class FolderResponse {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" folderId: ").append(toIndentedString(folderId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "labels", "name", "parent", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "name", "parent", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to FolderResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!FolderResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in FolderResponse is not found in the empty JSON string", FolderResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!FolderResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `FolderResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : FolderResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + if (!jsonObj.get("folderId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `folderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("folderId").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `parent` + Parent.validateJsonElement(jsonObj.get("parent")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!FolderResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'FolderResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(FolderResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, FolderResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public FolderResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of FolderResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of FolderResponse + * @throws IOException if the JSON string is invalid with respect to FolderResponse + */ + public static FolderResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, FolderResponse.class); + } + + /** + * Convert an instance of FolderResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetFolderDetailsResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetFolderDetailsResponse.java new file mode 100644 index 0000000..df480d2 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetFolderDetailsResponse.java @@ -0,0 +1,440 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Parent; +import cloud.stackit.sdk.resourcemanager.model.ParentListInner; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * GetFolderDetailsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class GetFolderDetailsResponse { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_FOLDER_ID = "folderId"; + @SerializedName(SERIALIZED_NAME_FOLDER_ID) + @javax.annotation.Nonnull + private UUID folderId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private Parent parent; + + public static final String SERIALIZED_NAME_PARENTS = "parents"; + @SerializedName(SERIALIZED_NAME_PARENTS) + @javax.annotation.Nullable + private List parents = new ArrayList<>(); + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public GetFolderDetailsResponse() { + } + + public GetFolderDetailsResponse containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique user-friendly identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public GetFolderDetailsResponse creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the folder was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public GetFolderDetailsResponse folderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + return this; + } + + /** + * Globally unique folder identifier. + * @return folderId + */ + @javax.annotation.Nonnull + public UUID getFolderId() { + return folderId; + } + + public void setFolderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + } + + + public GetFolderDetailsResponse labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public GetFolderDetailsResponse putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public GetFolderDetailsResponse name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Folder name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public GetFolderDetailsResponse parent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + return this; + } + + /** + * Get parent + * @return parent + */ + @javax.annotation.Nonnull + public Parent getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + } + + + public GetFolderDetailsResponse parents(@javax.annotation.Nullable List parents) { + this.parents = parents; + return this; + } + + public GetFolderDetailsResponse addParentsItem(ParentListInner parentsItem) { + if (this.parents == null) { + this.parents = new ArrayList<>(); + } + this.parents.add(parentsItem); + return this; + } + + /** + * Get parents + * @return parents + */ + @javax.annotation.Nullable + public List getParents() { + return parents; + } + + public void setParents(@javax.annotation.Nullable List parents) { + this.parents = parents; + } + + + public GetFolderDetailsResponse updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the folder was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetFolderDetailsResponse getFolderDetailsResponse = (GetFolderDetailsResponse) o; + return Objects.equals(this.containerId, getFolderDetailsResponse.containerId) && + Objects.equals(this.creationTime, getFolderDetailsResponse.creationTime) && + Objects.equals(this.folderId, getFolderDetailsResponse.folderId) && + Objects.equals(this.labels, getFolderDetailsResponse.labels) && + Objects.equals(this.name, getFolderDetailsResponse.name) && + Objects.equals(this.parent, getFolderDetailsResponse.parent) && + Objects.equals(this.parents, getFolderDetailsResponse.parents) && + Objects.equals(this.updateTime, getFolderDetailsResponse.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, folderId, labels, name, parent, parents, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetFolderDetailsResponse {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" folderId: ").append(toIndentedString(folderId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" parents: ").append(toIndentedString(parents)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "labels", "name", "parent", "parents", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "name", "parent", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetFolderDetailsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetFolderDetailsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GetFolderDetailsResponse is not found in the empty JSON string", GetFolderDetailsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetFolderDetailsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetFolderDetailsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetFolderDetailsResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + if (!jsonObj.get("folderId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `folderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("folderId").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `parent` + Parent.validateJsonElement(jsonObj.get("parent")); + if (jsonObj.get("parents") != null && !jsonObj.get("parents").isJsonNull()) { + JsonArray jsonArrayparents = jsonObj.getAsJsonArray("parents"); + if (jsonArrayparents != null) { + // ensure the json data is an array + if (!jsonObj.get("parents").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `parents` to be an array in the JSON string but got `%s`", jsonObj.get("parents").toString())); + } + + // validate the optional field `parents` (array) + for (int i = 0; i < jsonArrayparents.size(); i++) { + ParentListInner.validateJsonElement(jsonArrayparents.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetFolderDetailsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetFolderDetailsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetFolderDetailsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetFolderDetailsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetFolderDetailsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetFolderDetailsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetFolderDetailsResponse + * @throws IOException if the JSON string is invalid with respect to GetFolderDetailsResponse + */ + public static GetFolderDetailsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetFolderDetailsResponse.class); + } + + /** + * Convert an instance of GetFolderDetailsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetProjectResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetProjectResponse.java new file mode 100644 index 0000000..a6945dc --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/GetProjectResponse.java @@ -0,0 +1,469 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.LifecycleState; +import cloud.stackit.sdk.resourcemanager.model.Parent; +import cloud.stackit.sdk.resourcemanager.model.ParentListInner; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * GetProjectResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class GetProjectResponse { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LIFECYCLE_STATE = "lifecycleState"; + @SerializedName(SERIALIZED_NAME_LIFECYCLE_STATE) + @javax.annotation.Nonnull + private LifecycleState lifecycleState; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private Parent parent; + + public static final String SERIALIZED_NAME_PARENTS = "parents"; + @SerializedName(SERIALIZED_NAME_PARENTS) + @javax.annotation.Nullable + private List parents = new ArrayList<>(); + + public static final String SERIALIZED_NAME_PROJECT_ID = "projectId"; + @SerializedName(SERIALIZED_NAME_PROJECT_ID) + @javax.annotation.Nonnull + private UUID projectId; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public GetProjectResponse() { + } + + public GetProjectResponse containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public GetProjectResponse creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the project was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public GetProjectResponse labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public GetProjectResponse putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public GetProjectResponse lifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + /** + * Get lifecycleState + * @return lifecycleState + */ + @javax.annotation.Nonnull + public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + + public GetProjectResponse name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Project name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public GetProjectResponse parent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + return this; + } + + /** + * Get parent + * @return parent + */ + @javax.annotation.Nonnull + public Parent getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + } + + + public GetProjectResponse parents(@javax.annotation.Nullable List parents) { + this.parents = parents; + return this; + } + + public GetProjectResponse addParentsItem(ParentListInner parentsItem) { + if (this.parents == null) { + this.parents = new ArrayList<>(); + } + this.parents.add(parentsItem); + return this; + } + + /** + * Get parents + * @return parents + */ + @javax.annotation.Nullable + public List getParents() { + return parents; + } + + public void setParents(@javax.annotation.Nullable List parents) { + this.parents = parents; + } + + + public GetProjectResponse projectId(@javax.annotation.Nonnull UUID projectId) { + this.projectId = projectId; + return this; + } + + /** + * Globally unique identifier. + * @return projectId + */ + @javax.annotation.Nonnull + public UUID getProjectId() { + return projectId; + } + + public void setProjectId(@javax.annotation.Nonnull UUID projectId) { + this.projectId = projectId; + } + + + public GetProjectResponse updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the project was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetProjectResponse getProjectResponse = (GetProjectResponse) o; + return Objects.equals(this.containerId, getProjectResponse.containerId) && + Objects.equals(this.creationTime, getProjectResponse.creationTime) && + Objects.equals(this.labels, getProjectResponse.labels) && + Objects.equals(this.lifecycleState, getProjectResponse.lifecycleState) && + Objects.equals(this.name, getProjectResponse.name) && + Objects.equals(this.parent, getProjectResponse.parent) && + Objects.equals(this.parents, getProjectResponse.parents) && + Objects.equals(this.projectId, getProjectResponse.projectId) && + Objects.equals(this.updateTime, getProjectResponse.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, labels, lifecycleState, name, parent, parents, projectId, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetProjectResponse {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" parents: ").append(toIndentedString(parents)).append("\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "labels", "lifecycleState", "name", "parent", "parents", "projectId", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "lifecycleState", "name", "parent", "projectId", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetProjectResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetProjectResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in GetProjectResponse is not found in the empty JSON string", GetProjectResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetProjectResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GetProjectResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : GetProjectResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + // validate the required field `lifecycleState` + LifecycleState.validateJsonElement(jsonObj.get("lifecycleState")); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `parent` + Parent.validateJsonElement(jsonObj.get("parent")); + if (jsonObj.get("parents") != null && !jsonObj.get("parents").isJsonNull()) { + JsonArray jsonArrayparents = jsonObj.getAsJsonArray("parents"); + if (jsonArrayparents != null) { + // ensure the json data is an array + if (!jsonObj.get("parents").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `parents` to be an array in the JSON string but got `%s`", jsonObj.get("parents").toString())); + } + + // validate the optional field `parents` (array) + for (int i = 0; i < jsonArrayparents.size(); i++) { + ParentListInner.validateJsonElement(jsonArrayparents.get(i)); + }; + } + } + if (!jsonObj.get("projectId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `projectId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("projectId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetProjectResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetProjectResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(GetProjectResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, GetProjectResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetProjectResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of GetProjectResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetProjectResponse + * @throws IOException if the JSON string is invalid with respect to GetProjectResponse + */ + public static GetProjectResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetProjectResponse.class); + } + + /** + * Convert an instance of GetProjectResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/LifecycleState.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/LifecycleState.java new file mode 100644 index 0000000..186b7d3 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/LifecycleState.java @@ -0,0 +1,82 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Lifecycle state of the resource container. | LIFECYCLE STATE | DESCRIPTION | |----------|--------------------| | CREATING | The creation process has been triggered. The state remains until resource manager gets notified about successful process completion. | | ACTIVE | Resource container can be fully used. | | INACTIVE | Resource container usage has been disabled. | | DELETING | The deletion process has been triggered. The state remains until resource manager gets notified about successful process completion. Afterwards, the record will be deleted. | + */ +@JsonAdapter(LifecycleState.Adapter.class) +public enum LifecycleState { + + CREATING("CREATING"), + + ACTIVE("ACTIVE"), + + DELETING("DELETING"), + + INACTIVE("INACTIVE"); + + private String value; + + LifecycleState(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static LifecycleState fromValue(String value) { + for (LifecycleState b : LifecycleState.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final LifecycleState enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public LifecycleState read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return LifecycleState.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + LifecycleState.fromValue(value); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponse.java new file mode 100644 index 0000000..7f58ece --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponse.java @@ -0,0 +1,286 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.ListFoldersResponseItemsInner; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ListFoldersResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ListFoldersResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LIMIT = "limit"; + @SerializedName(SERIALIZED_NAME_LIMIT) + @javax.annotation.Nonnull + private BigDecimal limit = new BigDecimal("50"); + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + @SerializedName(SERIALIZED_NAME_OFFSET) + @javax.annotation.Nonnull + private BigDecimal offset = new BigDecimal("0"); + + public ListFoldersResponse() { + } + + public ListFoldersResponse items(@javax.annotation.Nonnull List items) { + this.items = items; + return this; + } + + public ListFoldersResponse addItemsItem(ListFoldersResponseItemsInner itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * @return items + */ + @javax.annotation.Nonnull + public List getItems() { + return items; + } + + public void setItems(@javax.annotation.Nonnull List items) { + this.items = items; + } + + + public ListFoldersResponse limit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + return this; + } + + /** + * The maximum number of projects to return in the response. If not present, an appropriate default will be used. + * minimum: 0 + * maximum: 100 + * @return limit + */ + @javax.annotation.Nonnull + public BigDecimal getLimit() { + return limit; + } + + public void setLimit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + } + + + public ListFoldersResponse offset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + return this; + } + + /** + * The offset of the first item in the collection to return. + * minimum: 0 + * @return offset + */ + @javax.annotation.Nonnull + public BigDecimal getOffset() { + return offset; + } + + public void setOffset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListFoldersResponse listFoldersResponse = (ListFoldersResponse) o; + return Objects.equals(this.items, listFoldersResponse.items) && + Objects.equals(this.limit, listFoldersResponse.limit) && + Objects.equals(this.offset, listFoldersResponse.offset); + } + + @Override + public int hashCode() { + return Objects.hash(items, limit, offset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListFoldersResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("items", "limit", "offset")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("items", "limit", "offset")); + } + + /** + * 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 ListFoldersResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListFoldersResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListFoldersResponse is not found in the empty JSON string", ListFoldersResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListFoldersResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListFoldersResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListFoldersResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + ListFoldersResponseItemsInner.validateJsonElement(jsonArrayitems.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListFoldersResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListFoldersResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListFoldersResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListFoldersResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListFoldersResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListFoldersResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListFoldersResponse + * @throws IOException if the JSON string is invalid with respect to ListFoldersResponse + */ + public static ListFoldersResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListFoldersResponse.class); + } + + /** + * Convert an instance of ListFoldersResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponseItemsInner.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponseItemsInner.java new file mode 100644 index 0000000..5a55e00 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListFoldersResponseItemsInner.java @@ -0,0 +1,389 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Parent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ListFoldersResponseItemsInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ListFoldersResponseItemsInner { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_FOLDER_ID = "folderId"; + @SerializedName(SERIALIZED_NAME_FOLDER_ID) + @javax.annotation.Nonnull + private UUID folderId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private Parent parent; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public ListFoldersResponseItemsInner() { + } + + public ListFoldersResponseItemsInner containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique folder identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public ListFoldersResponseItemsInner creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the folder was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public ListFoldersResponseItemsInner folderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + return this; + } + + /** + * Globally unique folder identifier. + * @return folderId + */ + @javax.annotation.Nonnull + public UUID getFolderId() { + return folderId; + } + + public void setFolderId(@javax.annotation.Nonnull UUID folderId) { + this.folderId = folderId; + } + + + public ListFoldersResponseItemsInner labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public ListFoldersResponseItemsInner putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public ListFoldersResponseItemsInner name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Name of the folder. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public ListFoldersResponseItemsInner parent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + return this; + } + + /** + * Get parent + * @return parent + */ + @javax.annotation.Nonnull + public Parent getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + } + + + public ListFoldersResponseItemsInner updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the folder was created. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListFoldersResponseItemsInner listFoldersResponseItemsInner = (ListFoldersResponseItemsInner) o; + return Objects.equals(this.containerId, listFoldersResponseItemsInner.containerId) && + Objects.equals(this.creationTime, listFoldersResponseItemsInner.creationTime) && + Objects.equals(this.folderId, listFoldersResponseItemsInner.folderId) && + Objects.equals(this.labels, listFoldersResponseItemsInner.labels) && + Objects.equals(this.name, listFoldersResponseItemsInner.name) && + Objects.equals(this.parent, listFoldersResponseItemsInner.parent) && + Objects.equals(this.updateTime, listFoldersResponseItemsInner.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, folderId, labels, name, parent, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListFoldersResponseItemsInner {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" folderId: ").append(toIndentedString(folderId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "labels", "name", "parent", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "folderId", "name", "parent", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListFoldersResponseItemsInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListFoldersResponseItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListFoldersResponseItemsInner is not found in the empty JSON string", ListFoldersResponseItemsInner.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListFoldersResponseItemsInner.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListFoldersResponseItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListFoldersResponseItemsInner.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + if (!jsonObj.get("folderId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `folderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("folderId").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `parent` + Parent.validateJsonElement(jsonObj.get("parent")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListFoldersResponseItemsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListFoldersResponseItemsInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListFoldersResponseItemsInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListFoldersResponseItemsInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListFoldersResponseItemsInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListFoldersResponseItemsInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListFoldersResponseItemsInner + * @throws IOException if the JSON string is invalid with respect to ListFoldersResponseItemsInner + */ + public static ListFoldersResponseItemsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListFoldersResponseItemsInner.class); + } + + /** + * Convert an instance of ListFoldersResponseItemsInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponse.java new file mode 100644 index 0000000..8084b8e --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponse.java @@ -0,0 +1,286 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.ListOrganizationsResponseItemsInner; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ListOrganizationsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ListOrganizationsResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LIMIT = "limit"; + @SerializedName(SERIALIZED_NAME_LIMIT) + @javax.annotation.Nonnull + private BigDecimal limit = new BigDecimal("50"); + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + @SerializedName(SERIALIZED_NAME_OFFSET) + @javax.annotation.Nonnull + private BigDecimal offset = new BigDecimal("0"); + + public ListOrganizationsResponse() { + } + + public ListOrganizationsResponse items(@javax.annotation.Nonnull List items) { + this.items = items; + return this; + } + + public ListOrganizationsResponse addItemsItem(ListOrganizationsResponseItemsInner itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * @return items + */ + @javax.annotation.Nonnull + public List getItems() { + return items; + } + + public void setItems(@javax.annotation.Nonnull List items) { + this.items = items; + } + + + public ListOrganizationsResponse limit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + return this; + } + + /** + * The maximum number of projects to return in the response. If not present, an appropriate default will be used. + * minimum: 0 + * maximum: 100 + * @return limit + */ + @javax.annotation.Nonnull + public BigDecimal getLimit() { + return limit; + } + + public void setLimit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + } + + + public ListOrganizationsResponse offset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + return this; + } + + /** + * The offset of the first item in the collection to return. + * minimum: 0 + * @return offset + */ + @javax.annotation.Nonnull + public BigDecimal getOffset() { + return offset; + } + + public void setOffset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListOrganizationsResponse listOrganizationsResponse = (ListOrganizationsResponse) o; + return Objects.equals(this.items, listOrganizationsResponse.items) && + Objects.equals(this.limit, listOrganizationsResponse.limit) && + Objects.equals(this.offset, listOrganizationsResponse.offset); + } + + @Override + public int hashCode() { + return Objects.hash(items, limit, offset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListOrganizationsResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("items", "limit", "offset")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("items", "limit", "offset")); + } + + /** + * 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 ListOrganizationsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListOrganizationsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListOrganizationsResponse is not found in the empty JSON string", ListOrganizationsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListOrganizationsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListOrganizationsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListOrganizationsResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + ListOrganizationsResponseItemsInner.validateJsonElement(jsonArrayitems.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListOrganizationsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListOrganizationsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListOrganizationsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListOrganizationsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListOrganizationsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListOrganizationsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListOrganizationsResponse + * @throws IOException if the JSON string is invalid with respect to ListOrganizationsResponse + */ + public static ListOrganizationsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListOrganizationsResponse.class); + } + + /** + * Convert an instance of ListOrganizationsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponseItemsInner.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponseItemsInner.java new file mode 100644 index 0000000..f0478e7 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListOrganizationsResponseItemsInner.java @@ -0,0 +1,389 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.LifecycleState; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ListOrganizationsResponseItemsInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ListOrganizationsResponseItemsInner { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LIFECYCLE_STATE = "lifecycleState"; + @SerializedName(SERIALIZED_NAME_LIFECYCLE_STATE) + @javax.annotation.Nonnull + private LifecycleState lifecycleState; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_ORGANIZATION_ID = "organizationId"; + @SerializedName(SERIALIZED_NAME_ORGANIZATION_ID) + @javax.annotation.Nonnull + private UUID organizationId; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public ListOrganizationsResponseItemsInner() { + } + + public ListOrganizationsResponseItemsInner containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique, user-friendly identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public ListOrganizationsResponseItemsInner creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the organization was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public ListOrganizationsResponseItemsInner labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public ListOrganizationsResponseItemsInner putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public ListOrganizationsResponseItemsInner lifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + /** + * Get lifecycleState + * @return lifecycleState + */ + @javax.annotation.Nonnull + public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + + public ListOrganizationsResponseItemsInner name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Name of the organization. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public ListOrganizationsResponseItemsInner organizationId(@javax.annotation.Nonnull UUID organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + * Globally unique, organization identifier. + * @return organizationId + */ + @javax.annotation.Nonnull + public UUID getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(@javax.annotation.Nonnull UUID organizationId) { + this.organizationId = organizationId; + } + + + public ListOrganizationsResponseItemsInner updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the organization was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListOrganizationsResponseItemsInner listOrganizationsResponseItemsInner = (ListOrganizationsResponseItemsInner) o; + return Objects.equals(this.containerId, listOrganizationsResponseItemsInner.containerId) && + Objects.equals(this.creationTime, listOrganizationsResponseItemsInner.creationTime) && + Objects.equals(this.labels, listOrganizationsResponseItemsInner.labels) && + Objects.equals(this.lifecycleState, listOrganizationsResponseItemsInner.lifecycleState) && + Objects.equals(this.name, listOrganizationsResponseItemsInner.name) && + Objects.equals(this.organizationId, listOrganizationsResponseItemsInner.organizationId) && + Objects.equals(this.updateTime, listOrganizationsResponseItemsInner.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, labels, lifecycleState, name, organizationId, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListOrganizationsResponseItemsInner {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "labels", "lifecycleState", "name", "organizationId", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "lifecycleState", "name", "organizationId", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListOrganizationsResponseItemsInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListOrganizationsResponseItemsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListOrganizationsResponseItemsInner is not found in the empty JSON string", ListOrganizationsResponseItemsInner.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListOrganizationsResponseItemsInner.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListOrganizationsResponseItemsInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListOrganizationsResponseItemsInner.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + // validate the required field `lifecycleState` + LifecycleState.validateJsonElement(jsonObj.get("lifecycleState")); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("organizationId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `organizationId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("organizationId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListOrganizationsResponseItemsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListOrganizationsResponseItemsInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListOrganizationsResponseItemsInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListOrganizationsResponseItemsInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListOrganizationsResponseItemsInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListOrganizationsResponseItemsInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListOrganizationsResponseItemsInner + * @throws IOException if the JSON string is invalid with respect to ListOrganizationsResponseItemsInner + */ + public static ListOrganizationsResponseItemsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListOrganizationsResponseItemsInner.class); + } + + /** + * Convert an instance of ListOrganizationsResponseItemsInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListProjectsResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListProjectsResponse.java new file mode 100644 index 0000000..352f0ff --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ListProjectsResponse.java @@ -0,0 +1,286 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.Project; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ListProjectsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ListProjectsResponse { + public static final String SERIALIZED_NAME_ITEMS = "items"; + @SerializedName(SERIALIZED_NAME_ITEMS) + @javax.annotation.Nonnull + private List items = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LIMIT = "limit"; + @SerializedName(SERIALIZED_NAME_LIMIT) + @javax.annotation.Nonnull + private BigDecimal limit = new BigDecimal("50"); + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + @SerializedName(SERIALIZED_NAME_OFFSET) + @javax.annotation.Nonnull + private BigDecimal offset = new BigDecimal("0"); + + public ListProjectsResponse() { + } + + public ListProjectsResponse items(@javax.annotation.Nonnull List items) { + this.items = items; + return this; + } + + public ListProjectsResponse addItemsItem(Project itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * Get items + * @return items + */ + @javax.annotation.Nonnull + public List getItems() { + return items; + } + + public void setItems(@javax.annotation.Nonnull List items) { + this.items = items; + } + + + public ListProjectsResponse limit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + return this; + } + + /** + * The maximum number of projects to return in the response. If not present, an appropriate default will be used. + * minimum: 0 + * maximum: 100 + * @return limit + */ + @javax.annotation.Nonnull + public BigDecimal getLimit() { + return limit; + } + + public void setLimit(@javax.annotation.Nonnull BigDecimal limit) { + this.limit = limit; + } + + + public ListProjectsResponse offset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + return this; + } + + /** + * The offset of the first item in the collection to return. + * minimum: 0 + * @return offset + */ + @javax.annotation.Nonnull + public BigDecimal getOffset() { + return offset; + } + + public void setOffset(@javax.annotation.Nonnull BigDecimal offset) { + this.offset = offset; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListProjectsResponse listProjectsResponse = (ListProjectsResponse) o; + return Objects.equals(this.items, listProjectsResponse.items) && + Objects.equals(this.limit, listProjectsResponse.limit) && + Objects.equals(this.offset, listProjectsResponse.offset); + } + + @Override + public int hashCode() { + return Objects.hash(items, limit, offset); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListProjectsResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" limit: ").append(toIndentedString(limit)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("items", "limit", "offset")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("items", "limit", "offset")); + } + + /** + * 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 ListProjectsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListProjectsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ListProjectsResponse is not found in the empty JSON string", ListProjectsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListProjectsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ListProjectsResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListProjectsResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("items").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `items` to be an array in the JSON string but got `%s`", jsonObj.get("items").toString())); + } + + JsonArray jsonArrayitems = jsonObj.getAsJsonArray("items"); + // validate the required field `items` (array) + for (int i = 0; i < jsonArrayitems.size(); i++) { + Project.validateJsonElement(jsonArrayitems.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListProjectsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListProjectsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListProjectsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListProjectsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListProjectsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListProjectsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListProjectsResponse + * @throws IOException if the JSON string is invalid with respect to ListProjectsResponse + */ + public static ListProjectsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListProjectsResponse.class); + } + + /** + * Convert an instance of ListProjectsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Member.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Member.java new file mode 100644 index 0000000..dad5ee9 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Member.java @@ -0,0 +1,241 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * Member + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class Member { + public static final String SERIALIZED_NAME_ROLE = "role"; + @SerializedName(SERIALIZED_NAME_ROLE) + @javax.annotation.Nonnull + private String role; + + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + @javax.annotation.Nonnull + private String subject; + + public Member() { + } + + public Member role(@javax.annotation.Nonnull String role) { + this.role = role; + return this; + } + + /** + * A valid role defined for the resource. + * @return role + */ + @javax.annotation.Nonnull + public String getRole() { + return role; + } + + public void setRole(@javax.annotation.Nonnull String role) { + this.role = role; + } + + + public Member subject(@javax.annotation.Nonnull String subject) { + this.subject = subject; + return this; + } + + /** + * Unique identifier of the user, service account or client. + * @return subject + */ + @javax.annotation.Nonnull + public String getSubject() { + return subject; + } + + public void setSubject(@javax.annotation.Nonnull String subject) { + this.subject = subject; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Member member = (Member) o; + return Objects.equals(this.role, member.role) && + Objects.equals(this.subject, member.subject); + } + + @Override + public int hashCode() { + return Objects.hash(role, subject); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Member {\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("role", "subject")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("role", "subject")); + } + + /** + * 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 Member + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Member.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Member is not found in the empty JSON string", Member.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Member.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Member` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Member.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("role").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `role` to be a primitive type in the JSON string but got `%s`", jsonObj.get("role").toString())); + } + if (!jsonObj.get("subject").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Member.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Member' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Member.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Member value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Member read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Member given an JSON string + * + * @param jsonString JSON string + * @return An instance of Member + * @throws IOException if the JSON string is invalid with respect to Member + */ + public static Member fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Member.class); + } + + /** + * Convert an instance of Member to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/OrganizationResponse.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/OrganizationResponse.java new file mode 100644 index 0000000..ea11527 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/OrganizationResponse.java @@ -0,0 +1,389 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.LifecycleState; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * OrganizationResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class OrganizationResponse { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LIFECYCLE_STATE = "lifecycleState"; + @SerializedName(SERIALIZED_NAME_LIFECYCLE_STATE) + @javax.annotation.Nonnull + private LifecycleState lifecycleState; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_ORGANIZATION_ID = "organizationId"; + @SerializedName(SERIALIZED_NAME_ORGANIZATION_ID) + @javax.annotation.Nonnull + private UUID organizationId; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public OrganizationResponse() { + } + + public OrganizationResponse containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique, user-friendly identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public OrganizationResponse creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the organization was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public OrganizationResponse labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public OrganizationResponse putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public OrganizationResponse lifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + /** + * Get lifecycleState + * @return lifecycleState + */ + @javax.annotation.Nonnull + public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + + public OrganizationResponse name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Organization name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public OrganizationResponse organizationId(@javax.annotation.Nonnull UUID organizationId) { + this.organizationId = organizationId; + return this; + } + + /** + * Globally unique, organization identifier. + * @return organizationId + */ + @javax.annotation.Nonnull + public UUID getOrganizationId() { + return organizationId; + } + + public void setOrganizationId(@javax.annotation.Nonnull UUID organizationId) { + this.organizationId = organizationId; + } + + + public OrganizationResponse updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the organization was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OrganizationResponse organizationResponse = (OrganizationResponse) o; + return Objects.equals(this.containerId, organizationResponse.containerId) && + Objects.equals(this.creationTime, organizationResponse.creationTime) && + Objects.equals(this.labels, organizationResponse.labels) && + Objects.equals(this.lifecycleState, organizationResponse.lifecycleState) && + Objects.equals(this.name, organizationResponse.name) && + Objects.equals(this.organizationId, organizationResponse.organizationId) && + Objects.equals(this.updateTime, organizationResponse.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, labels, lifecycleState, name, organizationId, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OrganizationResponse {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "labels", "lifecycleState", "name", "organizationId", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "lifecycleState", "name", "organizationId", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OrganizationResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OrganizationResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in OrganizationResponse is not found in the empty JSON string", OrganizationResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!OrganizationResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `OrganizationResponse` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : OrganizationResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + // validate the required field `lifecycleState` + LifecycleState.validateJsonElement(jsonObj.get("lifecycleState")); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if (!jsonObj.get("organizationId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `organizationId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("organizationId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OrganizationResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OrganizationResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(OrganizationResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, OrganizationResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OrganizationResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of OrganizationResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of OrganizationResponse + * @throws IOException if the JSON string is invalid with respect to OrganizationResponse + */ + public static OrganizationResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OrganizationResponse.class); + } + + /** + * Convert an instance of OrganizationResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Parent.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Parent.java new file mode 100644 index 0000000..29b34df --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Parent.java @@ -0,0 +1,325 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * Parent container. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class Parent { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + /** + * Container type of parent container. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + ORGANIZATION("ORGANIZATION"), + + FOLDER("FOLDER"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + TypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private TypeEnum type; + + public Parent() { + } + + public Parent containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * User-friendly identifier of either organization or folder (will replace id). + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public Parent id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Identifier of either organization or folder. + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + + public Parent type(@javax.annotation.Nonnull TypeEnum type) { + this.type = type; + return this; + } + + /** + * Container type of parent container. + * @return type + */ + @javax.annotation.Nonnull + public TypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull TypeEnum type) { + this.type = type; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Parent parent = (Parent) o; + return Objects.equals(this.containerId, parent.containerId) && + Objects.equals(this.id, parent.id) && + Objects.equals(this.type, parent.type); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, id, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Parent {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "id", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "id", "type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Parent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Parent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Parent is not found in the empty JSON string", Parent.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Parent.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Parent` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Parent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `type` + TypeEnum.validateJsonElement(jsonObj.get("type")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Parent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Parent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Parent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Parent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Parent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Parent given an JSON string + * + * @param jsonString JSON string + * @return An instance of Parent + * @throws IOException if the JSON string is invalid with respect to Parent + */ + public static Parent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Parent.class); + } + + /** + * Convert an instance of Parent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ParentListInner.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ParentListInner.java new file mode 100644 index 0000000..520421d --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/ParentListInner.java @@ -0,0 +1,412 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * ParentListInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class ParentListInner { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CONTAINER_PARENT_ID = "containerParentId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_PARENT_ID) + @javax.annotation.Nullable + private String containerParentId; + + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT_ID = "parentId"; + @SerializedName(SERIALIZED_NAME_PARENT_ID) + @javax.annotation.Nullable + private UUID parentId; + + /** + * Parent container type. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + FOLDER("FOLDER"), + + ORGANIZATION("ORGANIZATION"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + TypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private TypeEnum type; + + public ParentListInner() { + } + + public ParentListInner containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * User-friendly identifier of either organization or folder (will replace id). + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public ParentListInner containerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + return this; + } + + /** + * User-friendly parent identifier of either organization or folder (will replace parentId). + * @return containerParentId + */ + @javax.annotation.Nullable + public String getContainerParentId() { + return containerParentId; + } + + public void setContainerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + } + + + public ParentListInner id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * Identifier. + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + + public ParentListInner name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Parent container name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public ParentListInner parentId(@javax.annotation.Nullable UUID parentId) { + this.parentId = parentId; + return this; + } + + /** + * Identifier of the parent resource container. + * @return parentId + */ + @javax.annotation.Nullable + public UUID getParentId() { + return parentId; + } + + public void setParentId(@javax.annotation.Nullable UUID parentId) { + this.parentId = parentId; + } + + + public ParentListInner type(@javax.annotation.Nonnull TypeEnum type) { + this.type = type; + return this; + } + + /** + * Parent container type. + * @return type + */ + @javax.annotation.Nonnull + public TypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull TypeEnum type) { + this.type = type; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ParentListInner parentListInner = (ParentListInner) o; + return Objects.equals(this.containerId, parentListInner.containerId) && + Objects.equals(this.containerParentId, parentListInner.containerParentId) && + Objects.equals(this.id, parentListInner.id) && + Objects.equals(this.name, parentListInner.name) && + Objects.equals(this.parentId, parentListInner.parentId) && + Objects.equals(this.type, parentListInner.type); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, containerParentId, id, name, parentId, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ParentListInner {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" containerParentId: ").append(toIndentedString(containerParentId)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parentId: ").append(toIndentedString(parentId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "containerParentId", "id", "name", "parentId", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "id", "name", "type")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ParentListInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ParentListInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ParentListInner is not found in the empty JSON string", ParentListInner.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ParentListInner.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ParentListInner` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ParentListInner.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + if ((jsonObj.get("containerParentId") != null && !jsonObj.get("containerParentId").isJsonNull()) && !jsonObj.get("containerParentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerParentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerParentId").toString())); + } + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + if ((jsonObj.get("parentId") != null && !jsonObj.get("parentId").isJsonNull()) && !jsonObj.get("parentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `parentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("parentId").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + // validate the required field `type` + TypeEnum.validateJsonElement(jsonObj.get("type")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ParentListInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ParentListInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ParentListInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ParentListInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ParentListInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ParentListInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of ParentListInner + * @throws IOException if the JSON string is invalid with respect to ParentListInner + */ + public static ParentListInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ParentListInner.class); + } + + /** + * Convert an instance of ParentListInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateFolderPayload.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateFolderPayload.java new file mode 100644 index 0000000..b981de3 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateFolderPayload.java @@ -0,0 +1,270 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * PartialUpdateFolderPayload + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class PartialUpdateFolderPayload { + public static final String SERIALIZED_NAME_CONTAINER_PARENT_ID = "containerParentId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_PARENT_ID) + @javax.annotation.Nullable + private String containerParentId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable + private String name; + + public PartialUpdateFolderPayload() { + } + + public PartialUpdateFolderPayload containerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + return this; + } + + /** + * New parent identifier for the resource container - containerId as well as UUID identifier is supported. + * @return containerParentId + */ + @javax.annotation.Nullable + public String getContainerParentId() { + return containerParentId; + } + + public void setContainerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + } + + + public PartialUpdateFolderPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public PartialUpdateFolderPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public PartialUpdateFolderPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * New name for the resource container matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`. + * @return name + */ + @javax.annotation.Nullable + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartialUpdateFolderPayload partialUpdateFolderPayload = (PartialUpdateFolderPayload) o; + return Objects.equals(this.containerParentId, partialUpdateFolderPayload.containerParentId) && + Objects.equals(this.labels, partialUpdateFolderPayload.labels) && + Objects.equals(this.name, partialUpdateFolderPayload.name); + } + + @Override + public int hashCode() { + return Objects.hash(containerParentId, labels, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartialUpdateFolderPayload {\n"); + sb.append(" containerParentId: ").append(toIndentedString(containerParentId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerParentId", "labels", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PartialUpdateFolderPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PartialUpdateFolderPayload.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartialUpdateFolderPayload is not found in the empty JSON string", PartialUpdateFolderPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PartialUpdateFolderPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartialUpdateFolderPayload` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("containerParentId") != null && !jsonObj.get("containerParentId").isJsonNull()) && !jsonObj.get("containerParentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerParentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerParentId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartialUpdateFolderPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartialUpdateFolderPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartialUpdateFolderPayload.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartialUpdateFolderPayload value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartialUpdateFolderPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartialUpdateFolderPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartialUpdateFolderPayload + * @throws IOException if the JSON string is invalid with respect to PartialUpdateFolderPayload + */ + public static PartialUpdateFolderPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartialUpdateFolderPayload.class); + } + + /** + * Convert an instance of PartialUpdateFolderPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateOrganizationPayload.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateOrganizationPayload.java new file mode 100644 index 0000000..4d3be35 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateOrganizationPayload.java @@ -0,0 +1,241 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * PartialUpdateOrganizationPayload + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class PartialUpdateOrganizationPayload { + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable + private String name; + + public PartialUpdateOrganizationPayload() { + } + + public PartialUpdateOrganizationPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public PartialUpdateOrganizationPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public PartialUpdateOrganizationPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * The new name of the organization matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`. + * @return name + */ + @javax.annotation.Nullable + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartialUpdateOrganizationPayload partialUpdateOrganizationPayload = (PartialUpdateOrganizationPayload) o; + return Objects.equals(this.labels, partialUpdateOrganizationPayload.labels) && + Objects.equals(this.name, partialUpdateOrganizationPayload.name); + } + + @Override + public int hashCode() { + return Objects.hash(labels, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartialUpdateOrganizationPayload {\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("labels", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PartialUpdateOrganizationPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PartialUpdateOrganizationPayload.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartialUpdateOrganizationPayload is not found in the empty JSON string", PartialUpdateOrganizationPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PartialUpdateOrganizationPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartialUpdateOrganizationPayload` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartialUpdateOrganizationPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartialUpdateOrganizationPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartialUpdateOrganizationPayload.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartialUpdateOrganizationPayload value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartialUpdateOrganizationPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartialUpdateOrganizationPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartialUpdateOrganizationPayload + * @throws IOException if the JSON string is invalid with respect to PartialUpdateOrganizationPayload + */ + public static PartialUpdateOrganizationPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartialUpdateOrganizationPayload.class); + } + + /** + * Convert an instance of PartialUpdateOrganizationPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateProjectPayload.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateProjectPayload.java new file mode 100644 index 0000000..57d95ea --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/PartialUpdateProjectPayload.java @@ -0,0 +1,270 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * PartialUpdateProjectPayload + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class PartialUpdateProjectPayload { + public static final String SERIALIZED_NAME_CONTAINER_PARENT_ID = "containerParentId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_PARENT_ID) + @javax.annotation.Nullable + private String containerParentId; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable + private String name; + + public PartialUpdateProjectPayload() { + } + + public PartialUpdateProjectPayload containerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + return this; + } + + /** + * New parent identifier for the resource container - containerId as well as UUID identifier is supported. + * @return containerParentId + */ + @javax.annotation.Nullable + public String getContainerParentId() { + return containerParentId; + } + + public void setContainerParentId(@javax.annotation.Nullable String containerParentId) { + this.containerParentId = containerParentId; + } + + + public PartialUpdateProjectPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public PartialUpdateProjectPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public PartialUpdateProjectPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * New name for the resource container matching the regex `^[a-zA-ZäüöÄÜÖ0-9]( ?[a-zA-ZäüöÄÜÖß0-9_+&-]){0,39}$`. + * @return name + */ + @javax.annotation.Nullable + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PartialUpdateProjectPayload partialUpdateProjectPayload = (PartialUpdateProjectPayload) o; + return Objects.equals(this.containerParentId, partialUpdateProjectPayload.containerParentId) && + Objects.equals(this.labels, partialUpdateProjectPayload.labels) && + Objects.equals(this.name, partialUpdateProjectPayload.name); + } + + @Override + public int hashCode() { + return Objects.hash(containerParentId, labels, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PartialUpdateProjectPayload {\n"); + sb.append(" containerParentId: ").append(toIndentedString(containerParentId)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerParentId", "labels", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PartialUpdateProjectPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PartialUpdateProjectPayload.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PartialUpdateProjectPayload is not found in the empty JSON string", PartialUpdateProjectPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PartialUpdateProjectPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PartialUpdateProjectPayload` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("containerParentId") != null && !jsonObj.get("containerParentId").isJsonNull()) && !jsonObj.get("containerParentId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerParentId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerParentId").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PartialUpdateProjectPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PartialUpdateProjectPayload' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PartialUpdateProjectPayload.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PartialUpdateProjectPayload value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PartialUpdateProjectPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PartialUpdateProjectPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of PartialUpdateProjectPayload + * @throws IOException if the JSON string is invalid with respect to PartialUpdateProjectPayload + */ + public static PartialUpdateProjectPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PartialUpdateProjectPayload.class); + } + + /** + * Convert an instance of PartialUpdateProjectPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Project.java b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Project.java new file mode 100644 index 0000000..d8e35d6 --- /dev/null +++ b/services/resourcemanager/src/main/java/cloud/stackit/sdk/resourcemanager/model/Project.java @@ -0,0 +1,418 @@ +/* + * Resource Manager API + * API v2 to manage resource containers - organizations, folders, projects incl. labels ### Resource Management STACKIT resource management handles the terms _Organization_, _Folder_, _Project_, _Label_, and the hierarchical structure between them. Technically, organizations, folders, and projects are _Resource Containers_ to which a _Label_ can be attached to. The STACKIT _Resource Manager_ provides CRUD endpoints to query and to modify the state. ### Organizations STACKIT organizations are the base element to create and to use cloud-resources. An organization is bound to one customer account. Organizations have a lifecycle. - Organizations are always the root node in resource hierarchy and do not have a parent ### Projects STACKIT projects are needed to use cloud-resources. Projects serve as wrapper for underlying technical structures and processes. Projects have a lifecycle. Projects compared to folders may have different policies. - Projects are optional, but mandatory for cloud-resource usage - A project can be created having either an organization, or a folder as parent - A project must not have a project as parent - Project names under the same parent must not be unique - Root organization cannot be changed ### Label STACKIT labels are key-value pairs including a resource container reference. Labels can be defined and attached freely to resource containers by which resources can be organized and queried. - Policy-based, immutable labels may exists + * + * The version of the OpenAPI document: 2.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.resourcemanager.model; + +import java.util.Objects; +import cloud.stackit.sdk.resourcemanager.model.LifecycleState; +import cloud.stackit.sdk.resourcemanager.model.Parent; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +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.Map; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import cloud.stackit.sdk.resourcemanager.JSON; + +/** + * Project + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.14.0") +public class Project { + public static final String SERIALIZED_NAME_CONTAINER_ID = "containerId"; + @SerializedName(SERIALIZED_NAME_CONTAINER_ID) + @javax.annotation.Nonnull + private String containerId; + + public static final String SERIALIZED_NAME_CREATION_TIME = "creationTime"; + @SerializedName(SERIALIZED_NAME_CREATION_TIME) + @javax.annotation.Nonnull + private OffsetDateTime creationTime; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable + private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LIFECYCLE_STATE = "lifecycleState"; + @SerializedName(SERIALIZED_NAME_LIFECYCLE_STATE) + @javax.annotation.Nonnull + private LifecycleState lifecycleState; + + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nonnull + private String name; + + public static final String SERIALIZED_NAME_PARENT = "parent"; + @SerializedName(SERIALIZED_NAME_PARENT) + @javax.annotation.Nonnull + private Parent parent; + + public static final String SERIALIZED_NAME_PROJECT_ID = "projectId"; + @SerializedName(SERIALIZED_NAME_PROJECT_ID) + @javax.annotation.Nonnull + private UUID projectId; + + public static final String SERIALIZED_NAME_UPDATE_TIME = "updateTime"; + @SerializedName(SERIALIZED_NAME_UPDATE_TIME) + @javax.annotation.Nonnull + private OffsetDateTime updateTime; + + public Project() { + } + + public Project containerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + return this; + } + + /** + * Globally unique, user-friendly identifier. + * @return containerId + */ + @javax.annotation.Nonnull + public String getContainerId() { + return containerId; + } + + public void setContainerId(@javax.annotation.Nonnull String containerId) { + this.containerId = containerId; + } + + + public Project creationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + return this; + } + + /** + * Timestamp at which the project was created. + * @return creationTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTime() { + return creationTime; + } + + public void setCreationTime(@javax.annotation.Nonnull OffsetDateTime creationTime) { + this.creationTime = creationTime; + } + + + public Project labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public Project putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels are key-value string pairs that can be attached to a resource container. Some labels may be enforced via policies. - A label key must match the regex `[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. - A label value must match the regex `^$|[A-ZÄÜÖa-zäüöß0-9_-]{1,64}`. + * @return labels + */ + @javax.annotation.Nullable + public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + + public Project lifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + return this; + } + + /** + * Get lifecycleState + * @return lifecycleState + */ + @javax.annotation.Nonnull + public LifecycleState getLifecycleState() { + return lifecycleState; + } + + public void setLifecycleState(@javax.annotation.Nonnull LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + } + + + public Project name(@javax.annotation.Nonnull String name) { + this.name = name; + return this; + } + + /** + * Project name. + * @return name + */ + @javax.annotation.Nonnull + public String getName() { + return name; + } + + public void setName(@javax.annotation.Nonnull String name) { + this.name = name; + } + + + public Project parent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + return this; + } + + /** + * Get parent + * @return parent + */ + @javax.annotation.Nonnull + public Parent getParent() { + return parent; + } + + public void setParent(@javax.annotation.Nonnull Parent parent) { + this.parent = parent; + } + + + public Project projectId(@javax.annotation.Nonnull UUID projectId) { + this.projectId = projectId; + return this; + } + + /** + * Globally unique, project identifier. + * @return projectId + */ + @javax.annotation.Nonnull + public UUID getProjectId() { + return projectId; + } + + public void setProjectId(@javax.annotation.Nonnull UUID projectId) { + this.projectId = projectId; + } + + + public Project updateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + return this; + } + + /** + * Timestamp at which the project was last modified. + * @return updateTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(@javax.annotation.Nonnull OffsetDateTime updateTime) { + this.updateTime = updateTime; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Project project = (Project) o; + return Objects.equals(this.containerId, project.containerId) && + Objects.equals(this.creationTime, project.creationTime) && + Objects.equals(this.labels, project.labels) && + Objects.equals(this.lifecycleState, project.lifecycleState) && + Objects.equals(this.name, project.name) && + Objects.equals(this.parent, project.parent) && + Objects.equals(this.projectId, project.projectId) && + Objects.equals(this.updateTime, project.updateTime); + } + + @Override + public int hashCode() { + return Objects.hash(containerId, creationTime, labels, lifecycleState, name, parent, projectId, updateTime); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Project {\n"); + sb.append(" containerId: ").append(toIndentedString(containerId)).append("\n"); + sb.append(" creationTime: ").append(toIndentedString(creationTime)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" lifecycleState: ").append(toIndentedString(lifecycleState)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" parent: ").append(toIndentedString(parent)).append("\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" updateTime: ").append(toIndentedString(updateTime)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("containerId", "creationTime", "labels", "lifecycleState", "name", "parent", "projectId", "updateTime")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("containerId", "creationTime", "lifecycleState", "name", "parent", "projectId", "updateTime")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Project + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Project.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Project is not found in the empty JSON string", Project.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Project.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Project` properties. JSON: %s", entry.getKey(), jsonElement.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Project.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("containerId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `containerId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("containerId").toString())); + } + // validate the required field `lifecycleState` + LifecycleState.validateJsonElement(jsonObj.get("lifecycleState")); + if (!jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString())); + } + // validate the required field `parent` + Parent.validateJsonElement(jsonObj.get("parent")); + if (!jsonObj.get("projectId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `projectId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("projectId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Project.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Project' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Project.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Project value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Project read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Project given an JSON string + * + * @param jsonString JSON string + * @return An instance of Project + * @throws IOException if the JSON string is invalid with respect to Project + */ + public static Project fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Project.class); + } + + /** + * Convert an instance of Project to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +