serverVariables) {
+ this.serverVariables = serverVariables;
+ 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.iaas.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.iaas.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.iaas.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.iaas.ApiClient} object
+ */
+ public ApiClient setLocalDateFormat(DateTimeFormatter dateFormat) {
+ JSON.setLocalDateFormat(dateFormat);
+ return this;
+ }
+
+ /**
+ * Set LenientOnJson.
+ *
+ * @param lenientOnJson a boolean
+ * @return a {@link cloud.stackit.sdk.iaas.ApiClient} object
+ */
+ public ApiClient setLenientOnJson(boolean lenientOnJson) {
+ JSON.setLenientOnJson(lenientOnJson);
+ return this;
+ }
+
+ /**
+ * Set the User-Agent header's value (by adding to the default header map).
+ *
+ * @param userAgent HTTP request's user agent
+ * @return ApiClient
+ */
+ public ApiClient setUserAgent(String userAgent) {
+ addDefaultHeader("User-Agent", userAgent);
+ return this;
+ }
+
+ /**
+ * Add a default header.
+ *
+ * @param key The header's key
+ * @param value The header's value
+ * @return ApiClient
+ */
+ public ApiClient addDefaultHeader(String key, String value) {
+ defaultHeaderMap.put(key, value);
+ return this;
+ }
+
+ /**
+ * Add a default cookie.
+ *
+ * @param key The cookie's key
+ * @param value The cookie's value
+ * @return ApiClient
+ */
+ public ApiClient addDefaultCookie(String key, String value) {
+ defaultCookieMap.put(key, value);
+ return this;
+ }
+
+ /**
+ * Check that whether debugging is enabled for this API client.
+ *
+ * @return True if debugging is enabled, false otherwise.
+ */
+ public boolean isDebugging() {
+ return debugging;
+ }
+
+ /**
+ * Enable/disable debugging for this API client.
+ *
+ * @param debugging To enable (true) or disable (false) debugging
+ * @return ApiClient
+ */
+ public ApiClient setDebugging(boolean debugging) {
+ if (debugging != this.debugging) {
+ if (debugging) {
+ loggingInterceptor = new HttpLoggingInterceptor();
+ loggingInterceptor.setLevel(Level.BODY);
+ httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build();
+ } else {
+ final OkHttpClient.Builder builder = httpClient.newBuilder();
+ builder.interceptors().remove(loggingInterceptor);
+ httpClient = builder.build();
+ loggingInterceptor = null;
+ }
+ }
+ this.debugging = debugging;
+ return this;
+ }
+
+ /**
+ * The path of temporary folder used to store downloaded files from endpoints with file
+ * response. The default value is null
, i.e. using the system's default temporary
+ * folder.
+ *
+ * @see createTempFile
+ * @return Temporary folder path
+ */
+ public String getTempFolderPath() {
+ return tempFolderPath;
+ }
+
+ /**
+ * Set the temporary folder path (for downloading files)
+ *
+ * @param tempFolderPath Temporary folder path
+ * @return ApiClient
+ */
+ public ApiClient setTempFolderPath(String tempFolderPath) {
+ this.tempFolderPath = tempFolderPath;
+ return this;
+ }
+
+ /**
+ * Get connection timeout (in milliseconds).
+ *
+ * @return Timeout in milliseconds
+ */
+ public int getConnectTimeout() {
+ return httpClient.connectTimeoutMillis();
+ }
+
+ /**
+ * Sets the connect timeout (in milliseconds). A value of 0 means no timeout, otherwise values
+ * must be between 1 and {@link java.lang.Integer#MAX_VALUE}.
+ *
+ * @param connectionTimeout connection timeout in milliseconds
+ * @return Api client
+ */
+ public ApiClient setConnectTimeout(int connectionTimeout) {
+ httpClient =
+ httpClient
+ .newBuilder()
+ .connectTimeout(connectionTimeout, TimeUnit.MILLISECONDS)
+ .build();
+ return this;
+ }
+
+ /**
+ * Get read timeout (in milliseconds).
+ *
+ * @return Timeout in milliseconds
+ */
+ public int getReadTimeout() {
+ return httpClient.readTimeoutMillis();
+ }
+
+ /**
+ * Sets the read timeout (in milliseconds). A value of 0 means no timeout, otherwise values must
+ * be between 1 and {@link java.lang.Integer#MAX_VALUE}.
+ *
+ * @param readTimeout read timeout in milliseconds
+ * @return Api client
+ */
+ public ApiClient setReadTimeout(int readTimeout) {
+ httpClient =
+ httpClient.newBuilder().readTimeout(readTimeout, TimeUnit.MILLISECONDS).build();
+ return this;
+ }
+
+ /**
+ * Get write timeout (in milliseconds).
+ *
+ * @return Timeout in milliseconds
+ */
+ public int getWriteTimeout() {
+ return httpClient.writeTimeoutMillis();
+ }
+
+ /**
+ * Sets the write timeout (in milliseconds). A value of 0 means no timeout, otherwise values
+ * must be between 1 and {@link java.lang.Integer#MAX_VALUE}.
+ *
+ * @param writeTimeout connection timeout in milliseconds
+ * @return Api client
+ */
+ public ApiClient setWriteTimeout(int writeTimeout) {
+ httpClient =
+ httpClient.newBuilder().writeTimeout(writeTimeout, TimeUnit.MILLISECONDS).build();
+ return this;
+ }
+
+ /**
+ * Format the given parameter object into string.
+ *
+ * @param param Parameter
+ * @return String representation of the parameter
+ */
+ public String parameterToString(Object param) {
+ if (param == null) {
+ return "";
+ } else if (param instanceof Date
+ || param instanceof OffsetDateTime
+ || param instanceof LocalDate) {
+ // Serialize to json string and remove the " enclosing characters
+ String jsonStr = JSON.serialize(param);
+ return jsonStr.substring(1, jsonStr.length() - 1);
+ } else if (param instanceof Collection) {
+ StringBuilder b = new StringBuilder();
+ for (Object o : (Collection) param) {
+ if (b.length() > 0) {
+ b.append(",");
+ }
+ b.append(o);
+ }
+ return b.toString();
+ } else {
+ return String.valueOf(param);
+ }
+ }
+
+ /**
+ * Formats the specified query parameter to a list containing a single {@code Pair} object.
+ *
+ * Note that {@code value} must not be a collection.
+ *
+ * @param name The name of the parameter.
+ * @param value The value of the parameter.
+ * @return A list containing a single {@code Pair} object.
+ */
+ public List parameterToPair(String name, Object value) {
+ List params = new ArrayList();
+
+ // preconditions
+ if (name == null || name.isEmpty() || value == null || value instanceof Collection) {
+ return params;
+ }
+
+ params.add(new Pair(name, parameterToString(value)));
+ return params;
+ }
+
+ /**
+ * Formats the specified collection query parameters to a list of {@code Pair} objects.
+ *
+ * Note that the values of each of the returned Pair objects are percent-encoded.
+ *
+ * @param collectionFormat The collection format of the parameter.
+ * @param name The name of the parameter.
+ * @param value The value of the parameter.
+ * @return A list of {@code Pair} objects.
+ */
+ public List parameterToPairs(String collectionFormat, String name, Collection value) {
+ List params = new ArrayList();
+
+ // preconditions
+ if (name == null || name.isEmpty() || value == null || value.isEmpty()) {
+ return params;
+ }
+
+ // create the params based on the collection format
+ if ("multi".equals(collectionFormat)) {
+ for (Object item : value) {
+ params.add(new Pair(name, escapeString(parameterToString(item))));
+ }
+ return params;
+ }
+
+ // collectionFormat is assumed to be "csv" by default
+ String delimiter = ",";
+
+ // escape all delimiters except commas, which are URI reserved
+ // characters
+ if ("ssv".equals(collectionFormat)) {
+ delimiter = escapeString(" ");
+ } else if ("tsv".equals(collectionFormat)) {
+ delimiter = escapeString("\t");
+ } else if ("pipes".equals(collectionFormat)) {
+ delimiter = escapeString("|");
+ }
+
+ StringBuilder sb = new StringBuilder();
+ for (Object item : value) {
+ sb.append(delimiter);
+ sb.append(escapeString(parameterToString(item)));
+ }
+
+ params.add(new Pair(name, sb.substring(delimiter.length())));
+
+ return params;
+ }
+
+ /**
+ * Formats the specified free-form query parameters to a list of {@code Pair} objects.
+ *
+ * @param value The free-form query parameters.
+ * @return A list of {@code Pair} objects.
+ */
+ public List freeFormParameterToPairs(Object value) {
+ List params = new ArrayList<>();
+
+ // preconditions
+ if (value == null || !(value instanceof Map)) {
+ return params;
+ }
+
+ @SuppressWarnings("unchecked")
+ final Map valuesMap = (Map) value;
+
+ for (Map.Entry entry : valuesMap.entrySet()) {
+ params.add(new Pair(entry.getKey(), parameterToString(entry.getValue())));
+ }
+
+ return params;
+ }
+
+ /**
+ * Formats the specified collection path parameter to a string value.
+ *
+ * @param collectionFormat The collection format of the parameter.
+ * @param value The value of the parameter.
+ * @return String representation of the parameter
+ */
+ public String collectionPathParameterToString(String collectionFormat, Collection value) {
+ // create the value based on the collection format
+ if ("multi".equals(collectionFormat)) {
+ // not valid for path params
+ return parameterToString(value);
+ }
+
+ // collectionFormat is assumed to be "csv" by default
+ String delimiter = ",";
+
+ if ("ssv".equals(collectionFormat)) {
+ delimiter = " ";
+ } else if ("tsv".equals(collectionFormat)) {
+ delimiter = "\t";
+ } else if ("pipes".equals(collectionFormat)) {
+ delimiter = "|";
+ }
+
+ StringBuilder sb = new StringBuilder();
+ for (Object item : value) {
+ sb.append(delimiter);
+ sb.append(parameterToString(item));
+ }
+
+ return sb.substring(delimiter.length());
+ }
+
+ /**
+ * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif
+ *
+ * @param filename The filename to be sanitized
+ * @return The sanitized filename
+ */
+ public String sanitizeFilename(String filename) {
+ return filename.replaceFirst("^.*[/\\\\]", "");
+ }
+
+ /**
+ * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json
+ * application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / *" is also
+ * default to JSON
+ *
+ * @param mime MIME (Multipurpose Internet Mail Extensions)
+ * @return True if the given MIME is JSON, false otherwise.
+ */
+ public boolean isJsonMime(String mime) {
+ String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$";
+ return mime != null && (mime.matches(jsonMime) || mime.equals("*/*"));
+ }
+
+ /**
+ * Select the Accept header's value from the given accepts array: if JSON exists in the given
+ * array, use it; otherwise use all of them (joining into a string)
+ *
+ * @param accepts The accepts array to select from
+ * @return The Accept header to use. If the given array is empty, null will be returned (not to
+ * set the Accept header explicitly).
+ */
+ public String selectHeaderAccept(String[] accepts) {
+ if (accepts.length == 0) {
+ return null;
+ }
+ for (String accept : accepts) {
+ if (isJsonMime(accept)) {
+ return accept;
+ }
+ }
+ return StringUtil.join(accepts, ",");
+ }
+
+ /**
+ * Select the Content-Type header's value from the given array: if JSON exists in the given
+ * array, use it; otherwise use the first one of the array.
+ *
+ * @param contentTypes The Content-Type array to select from
+ * @return The Content-Type header to use. If the given array is empty, returns null. If it
+ * matches "any", JSON will be used.
+ */
+ public String selectHeaderContentType(String[] contentTypes) {
+ if (contentTypes.length == 0) {
+ return null;
+ }
+
+ if (contentTypes[0].equals("*/*")) {
+ return "application/json";
+ }
+
+ for (String contentType : contentTypes) {
+ if (isJsonMime(contentType)) {
+ return contentType;
+ }
+ }
+
+ return contentTypes[0];
+ }
+
+ /**
+ * Escape the given string to be used as URL query value.
+ *
+ * @param str String to be escaped
+ * @return Escaped string
+ */
+ public String escapeString(String str) {
+ try {
+ return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20");
+ } catch (UnsupportedEncodingException e) {
+ return str;
+ }
+ }
+
+ /**
+ * Deserialize response body to Java object, according to the return type and the Content-Type
+ * response header.
+ *
+ * @param Type
+ * @param response HTTP response
+ * @param returnType The type of the Java object
+ * @return The deserialized Java object
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to deserialize response body,
+ * i.e. cannot read response body or the Content-Type of the response is not supported.
+ */
+ @SuppressWarnings("unchecked")
+ public T deserialize(Response response, Type returnType) throws ApiException {
+ if (response == null || returnType == null) {
+ return null;
+ }
+
+ if ("byte[]".equals(returnType.toString())) {
+ // Handle binary response (byte array).
+ try {
+ return (T) response.body().bytes();
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ } else if (returnType.equals(File.class)) {
+ // Handle file downloading.
+ return (T) downloadFileFromResponse(response);
+ }
+
+ ResponseBody respBody = response.body();
+ if (respBody == null) {
+ return null;
+ }
+
+ String contentType = response.headers().get("Content-Type");
+ if (contentType == null) {
+ // ensuring a default content type
+ contentType = "application/json";
+ }
+ try {
+ if (isJsonMime(contentType)) {
+ return JSON.deserialize(respBody.byteStream(), returnType);
+ } else if (returnType.equals(String.class)) {
+ String respBodyString = respBody.string();
+ if (respBodyString.isEmpty()) {
+ return null;
+ }
+ // Expecting string, return the raw response body.
+ return (T) respBodyString;
+ } else {
+ throw new ApiException(
+ "Content type \""
+ + contentType
+ + "\" is not supported for type: "
+ + returnType,
+ response.code(),
+ response.headers().toMultimap(),
+ response.body().string());
+ }
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ }
+
+ /**
+ * Serialize the given Java object into request body according to the object's class and the
+ * request Content-Type.
+ *
+ * @param obj The Java object
+ * @param contentType The request Content-Type
+ * @return The serialized request body
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the given object
+ */
+ public RequestBody serialize(Object obj, String contentType) throws ApiException {
+ if (obj instanceof byte[]) {
+ // Binary (byte array) body parameter support.
+ return RequestBody.create((byte[]) obj, MediaType.parse(contentType));
+ } else if (obj instanceof File) {
+ // File body parameter support.
+ return RequestBody.create((File) obj, MediaType.parse(contentType));
+ } else if ("text/plain".equals(contentType) && obj instanceof String) {
+ return RequestBody.create((String) obj, MediaType.parse(contentType));
+ } else if (isJsonMime(contentType)) {
+ String content;
+ if (obj != null) {
+ content = JSON.serialize(obj);
+ } else {
+ content = null;
+ }
+ return RequestBody.create(content, MediaType.parse(contentType));
+ } else if (obj instanceof String) {
+ return RequestBody.create((String) obj, MediaType.parse(contentType));
+ } else {
+ throw new ApiException("Content type \"" + contentType + "\" is not supported");
+ }
+ }
+
+ /**
+ * Download file from the given response.
+ *
+ * @param response An instance of the Response object
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to read file content from
+ * response and write to disk
+ * @return Downloaded file
+ */
+ public File downloadFileFromResponse(Response response) throws ApiException {
+ try {
+ File file = prepareDownloadFile(response);
+ BufferedSink sink = Okio.buffer(Okio.sink(file));
+ sink.writeAll(response.body().source());
+ sink.close();
+ return file;
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ }
+
+ /**
+ * Prepare file for download
+ *
+ * @param response An instance of the Response object
+ * @return Prepared file for the download
+ * @throws java.io.IOException If fail to prepare file for download
+ */
+ public File prepareDownloadFile(Response response) throws IOException {
+ String filename = null;
+ String contentDisposition = response.header("Content-Disposition");
+ if (contentDisposition != null && !"".equals(contentDisposition)) {
+ // Get filename from the Content-Disposition header.
+ Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?");
+ Matcher matcher = pattern.matcher(contentDisposition);
+ if (matcher.find()) {
+ filename = sanitizeFilename(matcher.group(1));
+ }
+ }
+
+ String prefix = null;
+ String suffix = null;
+ if (filename == null) {
+ prefix = "download-";
+ suffix = "";
+ } else {
+ int pos = filename.lastIndexOf(".");
+ if (pos == -1) {
+ prefix = filename + "-";
+ } else {
+ prefix = filename.substring(0, pos) + "-";
+ suffix = filename.substring(pos);
+ }
+ // Files.createTempFile requires the prefix to be at least three characters long
+ if (prefix.length() < 3) prefix = "download-";
+ }
+
+ if (tempFolderPath == null) return Files.createTempFile(prefix, suffix).toFile();
+ else return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile();
+ }
+
+ /**
+ * {@link #execute(Call, Type)}
+ *
+ * @param Type
+ * @param call An instance of the Call object
+ * @return ApiResponse<T>
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call
+ */
+ public ApiResponse execute(Call call) throws ApiException {
+ return execute(call, null);
+ }
+
+ /**
+ * Execute HTTP call and deserialize the HTTP response body into the given return type.
+ *
+ * @param returnType The return type used to deserialize HTTP response body
+ * @param The return type corresponding to (same with) returnType
+ * @param call Call
+ * @return ApiResponse object containing response status, headers and data, which is a Java
+ * object deserialized from response body and would be null when returnType is null.
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call
+ */
+ public ApiResponse execute(Call call, Type returnType) throws ApiException {
+ try {
+ Response response = call.execute();
+ T data = handleResponse(response, returnType);
+ return new ApiResponse(response.code(), response.headers().toMultimap(), data);
+ } catch (IOException e) {
+ throw new ApiException(e);
+ }
+ }
+
+ /**
+ * {@link #executeAsync(Call, Type, ApiCallback)}
+ *
+ * @param Type
+ * @param call An instance of the Call object
+ * @param callback ApiCallback<T>
+ */
+ public void executeAsync(Call call, ApiCallback callback) {
+ executeAsync(call, null, callback);
+ }
+
+ /**
+ * Execute HTTP call asynchronously.
+ *
+ * @param Type
+ * @param call The callback to be executed when the API call finishes
+ * @param returnType Return type
+ * @param callback ApiCallback
+ * @see #execute(Call, Type)
+ */
+ @SuppressWarnings("unchecked")
+ public void executeAsync(Call call, final Type returnType, final ApiCallback callback) {
+ call.enqueue(
+ new Callback() {
+ @Override
+ public void onFailure(Call call, IOException e) {
+ callback.onFailure(new ApiException(e), 0, null);
+ }
+
+ @Override
+ public void onResponse(Call call, Response response) throws IOException {
+ T result;
+ try {
+ result = (T) handleResponse(response, returnType);
+ } catch (ApiException e) {
+ callback.onFailure(e, response.code(), response.headers().toMultimap());
+ return;
+ } catch (Exception e) {
+ callback.onFailure(
+ new ApiException(e),
+ response.code(),
+ response.headers().toMultimap());
+ return;
+ }
+ callback.onSuccess(
+ result, response.code(), response.headers().toMultimap());
+ }
+ });
+ }
+
+ /**
+ * Handle the given response, return the deserialized object when the response is successful.
+ *
+ * @param Type
+ * @param response Response
+ * @param returnType Return type
+ * @return Type
+ * @throws cloud.stackit.sdk.core.exception.ApiException If the response has an unsuccessful
+ * status code or fail to deserialize the response body
+ */
+ public T handleResponse(Response response, Type returnType) throws ApiException {
+ if (response.isSuccessful()) {
+ if (returnType == null || response.code() == 204) {
+ // returning null if the returnType is not defined,
+ // or the status code is 204 (No Content)
+ if (response.body() != null) {
+ try {
+ response.body().close();
+ } catch (Exception e) {
+ throw new ApiException(
+ response.message(),
+ e,
+ response.code(),
+ response.headers().toMultimap());
+ }
+ }
+ return null;
+ } else {
+ return deserialize(response, returnType);
+ }
+ } else {
+ String respBody = null;
+ if (response.body() != null) {
+ try {
+ respBody = response.body().string();
+ } catch (IOException e) {
+ throw new ApiException(
+ response.message(),
+ e,
+ response.code(),
+ response.headers().toMultimap());
+ }
+ }
+ throw new ApiException(
+ response.message(), response.code(), response.headers().toMultimap(), respBody);
+ }
+ }
+
+ /**
+ * Build HTTP call with the given options.
+ *
+ * @param baseUrl The base URL
+ * @param path The sub-path of the HTTP URL
+ * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and
+ * "DELETE"
+ * @param queryParams The query parameters
+ * @param collectionQueryParams The collection query parameters
+ * @param body The request body object
+ * @param headerParams The header parameters
+ * @param cookieParams The cookie parameters
+ * @param formParams The form parameters
+ * @param authNames The authentications to apply
+ * @param callback Callback for upload/download progress
+ * @return The HTTP call
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body
+ * object
+ */
+ public Call buildCall(
+ String baseUrl,
+ String path,
+ String method,
+ List queryParams,
+ List collectionQueryParams,
+ Object body,
+ Map headerParams,
+ Map cookieParams,
+ Map formParams,
+ String[] authNames,
+ ApiCallback callback)
+ throws ApiException {
+ Request request =
+ buildRequest(
+ baseUrl,
+ path,
+ method,
+ queryParams,
+ collectionQueryParams,
+ body,
+ headerParams,
+ cookieParams,
+ formParams,
+ authNames,
+ callback);
+
+ return httpClient.newCall(request);
+ }
+
+ /**
+ * Build an HTTP request with the given options.
+ *
+ * @param baseUrl The base URL
+ * @param path The sub-path of the HTTP URL
+ * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and
+ * "DELETE"
+ * @param queryParams The query parameters
+ * @param collectionQueryParams The collection query parameters
+ * @param body The request body object
+ * @param headerParams The header parameters
+ * @param cookieParams The cookie parameters
+ * @param formParams The form parameters
+ * @param authNames The authentications to apply
+ * @param callback Callback for upload/download progress
+ * @return The HTTP request
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body
+ * object
+ */
+ public Request buildRequest(
+ String baseUrl,
+ String path,
+ String method,
+ List queryParams,
+ List collectionQueryParams,
+ Object body,
+ Map headerParams,
+ Map cookieParams,
+ Map formParams,
+ String[] authNames,
+ ApiCallback callback)
+ throws ApiException {
+ final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams);
+
+ // prepare HTTP request body
+ RequestBody reqBody;
+ String contentType = headerParams.get("Content-Type");
+ String contentTypePure = contentType;
+ if (contentTypePure != null && contentTypePure.contains(";")) {
+ contentTypePure = contentType.substring(0, contentType.indexOf(";"));
+ }
+ if (!HttpMethod.permitsRequestBody(method)) {
+ reqBody = null;
+ } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) {
+ reqBody = buildRequestBodyFormEncoding(formParams);
+ } else if ("multipart/form-data".equals(contentTypePure)) {
+ reqBody = buildRequestBodyMultipart(formParams);
+ } else if (body == null) {
+ if ("DELETE".equals(method)) {
+ // allow calling DELETE without sending a request body
+ reqBody = null;
+ } else {
+ // use an empty request body (for POST, PUT and PATCH)
+ reqBody =
+ RequestBody.create(
+ "", contentType == null ? null : MediaType.parse(contentType));
+ }
+ } else {
+ reqBody = serialize(body, contentType);
+ }
+
+ List updatedQueryParams = new ArrayList<>(queryParams);
+
+ final Request.Builder reqBuilder =
+ new Request.Builder()
+ .url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams));
+ processHeaderParams(headerParams, reqBuilder);
+ processCookieParams(cookieParams, reqBuilder);
+
+ // Associate callback with request (if not null) so interceptor can
+ // access it when creating ProgressResponseBody
+ reqBuilder.tag(callback);
+
+ Request request = null;
+
+ if (callback != null && reqBody != null) {
+ ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback);
+ request = reqBuilder.method(method, progressRequestBody).build();
+ } else {
+ request = reqBuilder.method(method, reqBody).build();
+ }
+
+ return request;
+ }
+
+ /**
+ * Build full URL by concatenating base path, the given sub path and query parameters.
+ *
+ * @param baseUrl The base URL
+ * @param path The sub path
+ * @param queryParams The query parameters
+ * @param collectionQueryParams The collection query parameters
+ * @return The full URL
+ */
+ public String buildUrl(
+ String baseUrl, String path, List queryParams, List collectionQueryParams) {
+ final StringBuilder url = new StringBuilder();
+ if (baseUrl != null) {
+ url.append(baseUrl).append(path);
+ } else {
+ String baseURL;
+ if (serverIndex != null) {
+ if (serverIndex < 0 || serverIndex >= servers.size()) {
+ throw new ArrayIndexOutOfBoundsException(
+ String.format(
+ "Invalid index %d when selecting the host settings. Must be less than %d",
+ serverIndex, servers.size()));
+ }
+ baseURL = servers.get(serverIndex).URL(serverVariables);
+ } else {
+ baseURL = basePath;
+ }
+ url.append(baseURL).append(path);
+ }
+
+ if (queryParams != null && !queryParams.isEmpty()) {
+ // support (constant) query string in `path`, e.g. "/posts?draft=1"
+ String prefix = path.contains("?") ? "&" : "?";
+ for (Pair param : queryParams) {
+ if (param.getValue() != null) {
+ if (prefix != null) {
+ url.append(prefix);
+ prefix = null;
+ } else {
+ url.append("&");
+ }
+ String value = parameterToString(param.getValue());
+ url.append(escapeString(param.getName()))
+ .append("=")
+ .append(escapeString(value));
+ }
+ }
+ }
+
+ if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) {
+ String prefix = url.toString().contains("?") ? "&" : "?";
+ for (Pair param : collectionQueryParams) {
+ if (param.getValue() != null) {
+ if (prefix != null) {
+ url.append(prefix);
+ prefix = null;
+ } else {
+ url.append("&");
+ }
+ String value = parameterToString(param.getValue());
+ // collection query parameter value already escaped as part of parameterToPairs
+ url.append(escapeString(param.getName())).append("=").append(value);
+ }
+ }
+ }
+
+ return url.toString();
+ }
+
+ /**
+ * Set header parameters to the request builder, including default headers.
+ *
+ * @param headerParams Header parameters in the form of Map
+ * @param reqBuilder Request.Builder
+ */
+ public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) {
+ for (Entry param : headerParams.entrySet()) {
+ reqBuilder.header(param.getKey(), parameterToString(param.getValue()));
+ }
+ for (Entry header : defaultHeaderMap.entrySet()) {
+ if (!headerParams.containsKey(header.getKey())) {
+ reqBuilder.header(header.getKey(), parameterToString(header.getValue()));
+ }
+ }
+ }
+
+ /**
+ * Set cookie parameters to the request builder, including default cookies.
+ *
+ * @param cookieParams Cookie parameters in the form of Map
+ * @param reqBuilder Request.Builder
+ */
+ public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) {
+ for (Entry param : cookieParams.entrySet()) {
+ reqBuilder.addHeader(
+ "Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
+ }
+ for (Entry param : defaultCookieMap.entrySet()) {
+ if (!cookieParams.containsKey(param.getKey())) {
+ reqBuilder.addHeader(
+ "Cookie", String.format("%s=%s", param.getKey(), param.getValue()));
+ }
+ }
+ }
+
+ /**
+ * Build a form-encoding request body with the given form parameters.
+ *
+ * @param formParams Form parameters in the form of Map
+ * @return RequestBody
+ */
+ public RequestBody buildRequestBodyFormEncoding(Map formParams) {
+ okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder();
+ for (Entry param : formParams.entrySet()) {
+ formBuilder.add(param.getKey(), parameterToString(param.getValue()));
+ }
+ return formBuilder.build();
+ }
+
+ /**
+ * Build a multipart (file uploading) request body with the given form parameters, which could
+ * contain text fields and file fields.
+ *
+ * @param formParams Form parameters in the form of Map
+ * @return RequestBody
+ */
+ public RequestBody buildRequestBodyMultipart(Map formParams) {
+ MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM);
+ for (Entry param : formParams.entrySet()) {
+ if (param.getValue() instanceof File) {
+ File file = (File) param.getValue();
+ addPartToMultiPartBuilder(mpBuilder, param.getKey(), file);
+ } else if (param.getValue() instanceof List) {
+ List list = (List) param.getValue();
+ for (Object item : list) {
+ if (item instanceof File) {
+ addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item);
+ } else {
+ addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue());
+ }
+ }
+ } else {
+ addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue());
+ }
+ }
+ return mpBuilder.build();
+ }
+
+ /**
+ * Guess Content-Type header from the given file (defaults to "application/octet-stream").
+ *
+ * @param file The given file
+ * @return The guessed Content-Type
+ */
+ public String guessContentTypeFromFile(File file) {
+ String contentType = URLConnection.guessContentTypeFromName(file.getName());
+ if (contentType == null) {
+ return "application/octet-stream";
+ } else {
+ return contentType;
+ }
+ }
+
+ /**
+ * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder.
+ *
+ * @param mpBuilder MultipartBody.Builder
+ * @param key The key of the Header element
+ * @param file The file to add to the Header
+ */
+ protected void addPartToMultiPartBuilder(
+ MultipartBody.Builder mpBuilder, String key, File file) {
+ Headers partHeaders =
+ Headers.of(
+ "Content-Disposition",
+ "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\"");
+ MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file));
+ mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType));
+ }
+
+ /**
+ * Add a Content-Disposition Header for the given key and complex object to the MultipartBody
+ * Builder.
+ *
+ * @param mpBuilder MultipartBody.Builder
+ * @param key The key of the Header element
+ * @param obj The complex object to add to the Header
+ */
+ protected void addPartToMultiPartBuilder(
+ MultipartBody.Builder mpBuilder, String key, Object obj) {
+ RequestBody requestBody;
+ if (obj instanceof String) {
+ requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain"));
+ } else {
+ String content;
+ if (obj != null) {
+ content = JSON.serialize(obj);
+ } else {
+ content = null;
+ }
+ requestBody = RequestBody.create(content, MediaType.parse("application/json"));
+ }
+
+ Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\"");
+ mpBuilder.addPart(partHeaders, requestBody);
+ }
+
+ /**
+ * Get network interceptor to add it to the httpClient to track download progress for async
+ * requests.
+ */
+ protected Interceptor getProgressInterceptor() {
+ return new Interceptor() {
+ @Override
+ public Response intercept(Interceptor.Chain chain) throws IOException {
+ final Request request = chain.request();
+ final Response originalResponse = chain.proceed(request);
+ if (request.tag() instanceof ApiCallback) {
+ final ApiCallback callback = (ApiCallback) request.tag();
+ return originalResponse
+ .newBuilder()
+ .body(new ProgressResponseBody(originalResponse.body(), callback))
+ .build();
+ }
+ return originalResponse;
+ }
+ };
+ }
+
+ /**
+ * Apply SSL related settings to httpClient according to the current values of verifyingSsl and
+ * sslCaCert.
+ */
+ protected void applySslSettings() {
+ try {
+ TrustManager[] trustManagers;
+ HostnameVerifier hostnameVerifier;
+ if (!verifyingSsl) {
+ trustManagers =
+ new TrustManager[] {
+ new X509TrustManager() {
+ @Override
+ public void checkClientTrusted(
+ java.security.cert.X509Certificate[] chain, String authType)
+ throws CertificateException {}
+
+ @Override
+ public void checkServerTrusted(
+ java.security.cert.X509Certificate[] chain, String authType)
+ throws CertificateException {}
+
+ @Override
+ public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+ return new java.security.cert.X509Certificate[] {};
+ }
+ }
+ };
+ hostnameVerifier =
+ new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ };
+ } else {
+ TrustManagerFactory trustManagerFactory =
+ TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+
+ if (sslCaCert == null) {
+ trustManagerFactory.init((KeyStore) null);
+ } else {
+ char[] password = null; // Any password will work.
+ CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
+ Collection extends Certificate> certificates =
+ certificateFactory.generateCertificates(sslCaCert);
+ if (certificates.isEmpty()) {
+ throw new IllegalArgumentException(
+ "expected non-empty set of trusted certificates");
+ }
+ KeyStore caKeyStore = newEmptyKeyStore(password);
+ int index = 0;
+ for (Certificate certificate : certificates) {
+ String certificateAlias = "ca" + (index++);
+ caKeyStore.setCertificateEntry(certificateAlias, certificate);
+ }
+ trustManagerFactory.init(caKeyStore);
+ }
+ trustManagers = trustManagerFactory.getTrustManagers();
+ hostnameVerifier = OkHostnameVerifier.INSTANCE;
+ }
+
+ SSLContext sslContext = SSLContext.getInstance("TLS");
+ sslContext.init(keyManagers, trustManagers, new SecureRandom());
+ httpClient =
+ httpClient
+ .newBuilder()
+ .sslSocketFactory(
+ sslContext.getSocketFactory(),
+ (X509TrustManager) trustManagers[0])
+ .hostnameVerifier(hostnameVerifier)
+ .build();
+ } catch (GeneralSecurityException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException {
+ try {
+ KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ keyStore.load(null, password);
+ return keyStore;
+ } catch (IOException e) {
+ throw new AssertionError(e);
+ }
+ }
+
+ /**
+ * Convert the HTTP request body to a string.
+ *
+ * @param requestBody The HTTP request object
+ * @return The string representation of the HTTP request body
+ * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body
+ * object into a string
+ */
+ protected String requestBodyToString(RequestBody requestBody) throws ApiException {
+ if (requestBody != null) {
+ try {
+ final Buffer buffer = new Buffer();
+ requestBody.writeTo(buffer);
+ return buffer.readUtf8();
+ } catch (final IOException e) {
+ throw new ApiException(e);
+ }
+ }
+
+ // empty http request body
+ return "";
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ApiResponse.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ApiResponse.java
new file mode 100644
index 0000000..9da9eeb
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ApiResponse.java
@@ -0,0 +1,73 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.util.List;
+import java.util.Map;
+
+/** API response returned by API call. */
+public class ApiResponse {
+ private final int statusCode;
+ private final Map> headers;
+ private final T data;
+
+ /**
+ * Constructor for ApiResponse.
+ *
+ * @param statusCode The status code of HTTP response
+ * @param headers The headers of HTTP response
+ */
+ public ApiResponse(int statusCode, Map> headers) {
+ this(statusCode, headers, null);
+ }
+
+ /**
+ * Constructor for ApiResponse.
+ *
+ * @param statusCode The status code of HTTP response
+ * @param headers The headers of HTTP response
+ * @param data The object deserialized from response bod
+ */
+ public ApiResponse(int statusCode, Map> headers, T data) {
+ this.statusCode = statusCode;
+ this.headers = headers;
+ this.data = data;
+ }
+
+ /**
+ * Get the status code
.
+ *
+ * @return the status code
+ */
+ public int getStatusCode() {
+ return statusCode;
+ }
+
+ /**
+ * Get the headers
.
+ *
+ * @return a {@link java.util.Map} of headers
+ */
+ public Map> getHeaders() {
+ return headers;
+ }
+
+ /**
+ * Get the data
.
+ *
+ * @return the data
+ */
+ public T getData() {
+ return data;
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/GzipRequestInterceptor.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/GzipRequestInterceptor.java
new file mode 100644
index 0000000..cb12462
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/GzipRequestInterceptor.java
@@ -0,0 +1,87 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.io.IOException;
+import okhttp3.*;
+import okio.Buffer;
+import okio.BufferedSink;
+import okio.GzipSink;
+import okio.Okio;
+
+/**
+ * Encodes request bodies using gzip.
+ *
+ * Taken from https://github.com/square/okhttp/issues/350
+ */
+class GzipRequestInterceptor implements Interceptor {
+ @Override
+ public Response intercept(Chain chain) throws IOException {
+ Request originalRequest = chain.request();
+ if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) {
+ return chain.proceed(originalRequest);
+ }
+
+ Request compressedRequest =
+ originalRequest
+ .newBuilder()
+ .header("Content-Encoding", "gzip")
+ .method(
+ originalRequest.method(),
+ forceContentLength(gzip(originalRequest.body())))
+ .build();
+ return chain.proceed(compressedRequest);
+ }
+
+ private RequestBody forceContentLength(final RequestBody requestBody) throws IOException {
+ final Buffer buffer = new Buffer();
+ requestBody.writeTo(buffer);
+ return new RequestBody() {
+ @Override
+ public MediaType contentType() {
+ return requestBody.contentType();
+ }
+
+ @Override
+ public long contentLength() {
+ return buffer.size();
+ }
+
+ @Override
+ public void writeTo(BufferedSink sink) throws IOException {
+ sink.write(buffer.snapshot());
+ }
+ };
+ }
+
+ private RequestBody gzip(final RequestBody body) {
+ return new RequestBody() {
+ @Override
+ public MediaType contentType() {
+ return body.contentType();
+ }
+
+ @Override
+ public long contentLength() {
+ return -1; // We don't know the compressed length in advance!
+ }
+
+ @Override
+ public void writeTo(BufferedSink sink) throws IOException {
+ BufferedSink gzipSink = Okio.buffer(new GzipSink(sink));
+ body.writeTo(gzipSink);
+ gzipSink.close();
+ }
+ };
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/JSON.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/JSON.java
new file mode 100644
index 0000000..210e683
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/JSON.java
@@ -0,0 +1,701 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import com.google.gson.TypeAdapter;
+import com.google.gson.internal.bind.util.ISO8601Utils;
+import com.google.gson.stream.JsonReader;
+import com.google.gson.stream.JsonWriter;
+import io.gsonfire.GsonFireBuilder;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.ParsePosition;
+import java.time.LocalDate;
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.Map;
+import okio.ByteString;
+
+/*
+ * A JSON utility class
+ *
+ * NOTE: in the future, this class may be converted to static, which may break
+ * backward-compatibility
+ */
+public class JSON {
+ private static Gson gson;
+ private static boolean isLenientOnJson = false;
+ private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter();
+ private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter();
+ private static OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter =
+ new OffsetDateTimeTypeAdapter();
+ private static LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter();
+ private static ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter();
+
+ @SuppressWarnings("unchecked")
+ public static GsonBuilder createGson() {
+ GsonFireBuilder fireBuilder = new GsonFireBuilder();
+ GsonBuilder builder = fireBuilder.createGsonBuilder();
+ return builder;
+ }
+
+ private static String getDiscriminatorValue(
+ JsonElement readElement, String discriminatorField) {
+ JsonElement element = readElement.getAsJsonObject().get(discriminatorField);
+ if (null == element) {
+ throw new IllegalArgumentException(
+ "missing discriminator field: <" + discriminatorField + ">");
+ }
+ return element.getAsString();
+ }
+
+ /**
+ * Returns the Java class that implements the OpenAPI schema for the specified discriminator
+ * value.
+ *
+ * @param classByDiscriminatorValue The map of discriminator values to Java classes.
+ * @param discriminatorValue The value of the OpenAPI discriminator in the input data.
+ * @return The Java class that implements the OpenAPI schema
+ */
+ private static Class getClassByDiscriminator(
+ Map classByDiscriminatorValue, String discriminatorValue) {
+ Class clazz = (Class) classByDiscriminatorValue.get(discriminatorValue);
+ if (null == clazz) {
+ throw new IllegalArgumentException(
+ "cannot determine model class of name: <" + discriminatorValue + ">");
+ }
+ return clazz;
+ }
+
+ static {
+ GsonBuilder gsonBuilder = createGson();
+ gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter);
+ gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter);
+ gsonBuilder.registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter);
+ gsonBuilder.registerTypeAdapter(LocalDate.class, localDateTypeAdapter);
+ gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter);
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AddVolumeToServerPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AffinityGroup.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AffinityGroupListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AllowedAddressesInner.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Area.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AreaConfig.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AreaId.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AreaPrefixConfigIPv4.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.AvailabilityZoneListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Backup.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.BackupListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.BackupSource.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.BaseSecurityGroupRule.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.BootVolume.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.BootVolumeSource.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateAffinityGroupPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateAreaAddressFamily
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateAreaIPv4.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateBackupPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateImagePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateKeyPairPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkAddressFamily
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkAreaPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkAreaRangePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkAreaRoutePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkIPv4Body.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkIPv6Body.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNetworkPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateNicPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateProtocol.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreatePublicIPPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateSecurityGroupPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateSecurityGroupRulePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateSecurityGroupRuleProtocol
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateServerNetworking.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateServerNetworkingWithNics
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateServerPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateServerPayloadNetworking
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateSnapshotPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.CreateVolumePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Error.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.GetServerLog200Response
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ICMPParameters.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Image.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageAgent.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageChecksum.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageConfig.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageCreateResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageShare.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ImageShareConsumer.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.KeyPairListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Keypair.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.MachineType.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.MachineTypeListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NIC.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NICListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Network.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkArea.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkAreaIPv4.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkAreaListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkRange.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.NetworkRangeListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PartialUpdateNetworkAreaPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PartialUpdateNetworkPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PortRange.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Project.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ProjectListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Protocol.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PublicIp.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PublicIpListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PublicNetwork.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.PublicNetworkListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Quota.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.QuotaList.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.QuotaListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Request.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.RequestResource.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.RescueServerPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ResizeServerPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ResizeVolumePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Route.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.RouteListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SecurityGroup.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SecurityGroupListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SecurityGroupRule.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SecurityGroupRuleListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SecurityGroupRuleProtocol
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Server.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ServerConsoleUrl.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ServerListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ServerMaintenance.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ServerNetwork.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.ServiceAccountMailListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SetImageSharePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Snapshot.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.SnapshotListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateAreaAddressFamily
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateAreaIPv4.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateAttachedVolumePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateBackupPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateImagePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateImageSharePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateKeyPairPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateNetworkAddressFamily
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateNetworkAreaRoutePayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateNetworkIPv4Body.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateNetworkIPv6Body.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateNicPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdatePublicIPPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateSecurityGroupPayload
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateServerPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateSnapshotPayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.UpdateVolumePayload.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.Volume.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumeAttachment.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumeAttachmentListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumeEncryptionParameter
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumeListResponse.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumePerformanceClass.CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumePerformanceClassListResponse
+ .CustomTypeAdapterFactory());
+ gsonBuilder.registerTypeAdapterFactory(
+ new cloud.stackit.sdk.iaas.model.VolumeSource.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/iaas/src/main/java/cloud/stackit/sdk/iaas/Pair.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/Pair.java
new file mode 100644
index 0000000..25a73fd
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/Pair.java
@@ -0,0 +1,38 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+@javax.annotation.Generated(
+ value = "org.openapitools.codegen.languages.JavaClientCodegen",
+ comments = "Generator version: 7.15.0")
+public class Pair {
+ private final String name;
+ private final String value;
+
+ public Pair(String name, String value) {
+ this.name = isValidString(name) ? name : "";
+ this.value = isValidString(value) ? value : "";
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
+
+ private static boolean isValidString(String arg) {
+ return arg != null;
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressRequestBody.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressRequestBody.java
new file mode 100644
index 0000000..0817b86
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressRequestBody.java
@@ -0,0 +1,71 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.io.IOException;
+import okhttp3.MediaType;
+import okhttp3.RequestBody;
+import okio.Buffer;
+import okio.BufferedSink;
+import okio.ForwardingSink;
+import okio.Okio;
+import okio.Sink;
+
+public class ProgressRequestBody extends RequestBody {
+
+ private final RequestBody requestBody;
+
+ private final ApiCallback callback;
+
+ public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) {
+ this.requestBody = requestBody;
+ this.callback = callback;
+ }
+
+ @Override
+ public MediaType contentType() {
+ return requestBody.contentType();
+ }
+
+ @Override
+ public long contentLength() throws IOException {
+ return requestBody.contentLength();
+ }
+
+ @Override
+ public void writeTo(BufferedSink sink) throws IOException {
+ BufferedSink bufferedSink = Okio.buffer(sink(sink));
+ requestBody.writeTo(bufferedSink);
+ bufferedSink.flush();
+ }
+
+ private Sink sink(Sink sink) {
+ return new ForwardingSink(sink) {
+
+ long bytesWritten = 0L;
+ long contentLength = 0L;
+
+ @Override
+ public void write(Buffer source, long byteCount) throws IOException {
+ super.write(source, byteCount);
+ if (contentLength == 0) {
+ contentLength = contentLength();
+ }
+
+ bytesWritten += byteCount;
+ callback.onUploadProgress(
+ bytesWritten, contentLength, bytesWritten == contentLength);
+ }
+ };
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressResponseBody.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressResponseBody.java
new file mode 100644
index 0000000..5a41d02
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ProgressResponseBody.java
@@ -0,0 +1,68 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.io.IOException;
+import okhttp3.MediaType;
+import okhttp3.ResponseBody;
+import okio.Buffer;
+import okio.BufferedSource;
+import okio.ForwardingSource;
+import okio.Okio;
+import okio.Source;
+
+public class ProgressResponseBody extends ResponseBody {
+
+ private final ResponseBody responseBody;
+ private final ApiCallback callback;
+ private BufferedSource bufferedSource;
+
+ public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) {
+ this.responseBody = responseBody;
+ this.callback = callback;
+ }
+
+ @Override
+ public MediaType contentType() {
+ return responseBody.contentType();
+ }
+
+ @Override
+ public long contentLength() {
+ return responseBody.contentLength();
+ }
+
+ @Override
+ public BufferedSource source() {
+ if (bufferedSource == null) {
+ bufferedSource = Okio.buffer(source(responseBody.source()));
+ }
+ return bufferedSource;
+ }
+
+ private Source source(Source source) {
+ return new ForwardingSource(source) {
+ long totalBytesRead = 0L;
+
+ @Override
+ public long read(Buffer sink, long byteCount) throws IOException {
+ long bytesRead = super.read(sink, byteCount);
+ // read() returns the number of bytes read, or -1 if this source is exhausted.
+ totalBytesRead += bytesRead != -1 ? bytesRead : 0;
+ callback.onDownloadProgress(
+ totalBytesRead, responseBody.contentLength(), bytesRead == -1);
+ return bytesRead;
+ }
+ };
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerConfiguration.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerConfiguration.java
new file mode 100644
index 0000000..37083c1
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerConfiguration.java
@@ -0,0 +1,79 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.util.Map;
+
+/** Representing a Server configuration. */
+@javax.annotation.Generated(
+ value = "org.openapitools.codegen.languages.JavaClientCodegen",
+ comments = "Generator version: 7.15.0")
+public class ServerConfiguration {
+ public String URL;
+ public String description;
+ public Map variables;
+
+ /**
+ * @param URL A URL to the target host.
+ * @param description A description of the host designated by the URL.
+ * @param variables A map between a variable name and its value. The value is used for
+ * substitution in the server's URL template.
+ */
+ public ServerConfiguration(
+ String URL, String description, Map variables) {
+ this.URL = URL;
+ this.description = description;
+ this.variables = variables;
+ }
+
+ /**
+ * Format URL template using given variables.
+ *
+ * @param variables A map between a variable name and its value.
+ * @return Formatted URL.
+ */
+ public String URL(Map variables) {
+ String url = this.URL;
+
+ // go through variables and replace placeholders
+ for (Map.Entry variable : this.variables.entrySet()) {
+ String name = variable.getKey();
+ ServerVariable serverVariable = variable.getValue();
+ String value = serverVariable.defaultValue;
+
+ if (variables != null && variables.containsKey(name)) {
+ value = variables.get(name);
+ if (serverVariable.enumValues.size() > 0
+ && !serverVariable.enumValues.contains(value)) {
+ throw new IllegalArgumentException(
+ "The variable "
+ + name
+ + " in the server URL has invalid value "
+ + value
+ + ".");
+ }
+ }
+ url = url.replace("{" + name + "}", value);
+ }
+ return url;
+ }
+
+ /**
+ * Format URL template using default server variables.
+ *
+ * @return Formatted URL.
+ */
+ public String URL() {
+ return URL(null);
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerVariable.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerVariable.java
new file mode 100644
index 0000000..b3e35f0
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/ServerVariable.java
@@ -0,0 +1,37 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.util.HashSet;
+
+/** Representing a Server Variable for server URL template substitution. */
+@javax.annotation.Generated(
+ value = "org.openapitools.codegen.languages.JavaClientCodegen",
+ comments = "Generator version: 7.15.0")
+public class ServerVariable {
+ public String description;
+ public String defaultValue;
+ public HashSet enumValues = null;
+
+ /**
+ * @param description A description for the server variable.
+ * @param defaultValue The default value to use for substitution.
+ * @param enumValues An enumeration of string values to be used if the substitution options are
+ * from a limited set.
+ */
+ public ServerVariable(String description, String defaultValue, HashSet enumValues) {
+ this.description = description;
+ this.defaultValue = defaultValue;
+ this.enumValues = enumValues;
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/StringUtil.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/StringUtil.java
new file mode 100644
index 0000000..8509051
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/StringUtil.java
@@ -0,0 +1,83 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+@javax.annotation.Generated(
+ value = "org.openapitools.codegen.languages.JavaClientCodegen",
+ comments = "Generator version: 7.15.0")
+public class StringUtil {
+ /**
+ * Check if the given array contains the given value (with case-insensitive comparison).
+ *
+ * @param array The array
+ * @param value The value to search
+ * @return true if the array contains the value
+ */
+ public static boolean containsIgnoreCase(String[] array, String value) {
+ for (String str : array) {
+ if (value == null && str == null) {
+ return true;
+ }
+ if (value != null && value.equalsIgnoreCase(str)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Join an array of strings with the given separator.
+ *
+ * Note: This might be replaced by utility method from commons-lang or guava someday if one
+ * of those libraries is added as dependency.
+ *
+ * @param array The array of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(String[] array, String separator) {
+ int len = array.length;
+ if (len == 0) {
+ return "";
+ }
+
+ StringBuilder out = new StringBuilder();
+ out.append(array[0]);
+ for (int i = 1; i < len; i++) {
+ out.append(separator).append(array[i]);
+ }
+ return out.toString();
+ }
+
+ /**
+ * Join a list of strings with the given separator.
+ *
+ * @param list The list of strings
+ * @param separator The separator
+ * @return the resulting string
+ */
+ public static String join(Collection list, String separator) {
+ Iterator iterator = list.iterator();
+ StringBuilder out = new StringBuilder();
+ if (iterator.hasNext()) {
+ out.append(iterator.next());
+ }
+ while (iterator.hasNext()) {
+ out.append(separator).append(iterator.next());
+ }
+ return out.toString();
+ }
+}
diff --git a/services/iaas/src/main/java/cloud/stackit/sdk/iaas/api/DefaultApi.java b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/api/DefaultApi.java
new file mode 100644
index 0000000..9ad35e5
--- /dev/null
+++ b/services/iaas/src/main/java/cloud/stackit/sdk/iaas/api/DefaultApi.java
@@ -0,0 +1,24757 @@
+/*
+ * IaaS-API
+ * This API allows you to create and modify IaaS resources.
+ *
+ * The version of the OpenAPI document: 1
+ * Contact: stackit-iaas@mail.schwarz
+ *
+ * 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.iaas.api;
+
+import cloud.stackit.sdk.core.config.CoreConfiguration;
+import cloud.stackit.sdk.core.exception.ApiException;
+import cloud.stackit.sdk.iaas.ApiCallback;
+import cloud.stackit.sdk.iaas.ApiClient;
+import cloud.stackit.sdk.iaas.ApiResponse;
+import cloud.stackit.sdk.iaas.Pair;
+import cloud.stackit.sdk.iaas.model.AddVolumeToServerPayload;
+import cloud.stackit.sdk.iaas.model.AffinityGroup;
+import cloud.stackit.sdk.iaas.model.AffinityGroupListResponse;
+import cloud.stackit.sdk.iaas.model.AvailabilityZoneListResponse;
+import cloud.stackit.sdk.iaas.model.Backup;
+import cloud.stackit.sdk.iaas.model.BackupListResponse;
+import cloud.stackit.sdk.iaas.model.CreateAffinityGroupPayload;
+import cloud.stackit.sdk.iaas.model.CreateBackupPayload;
+import cloud.stackit.sdk.iaas.model.CreateImagePayload;
+import cloud.stackit.sdk.iaas.model.CreateKeyPairPayload;
+import cloud.stackit.sdk.iaas.model.CreateNetworkAreaPayload;
+import cloud.stackit.sdk.iaas.model.CreateNetworkAreaRangePayload;
+import cloud.stackit.sdk.iaas.model.CreateNetworkAreaRoutePayload;
+import cloud.stackit.sdk.iaas.model.CreateNetworkPayload;
+import cloud.stackit.sdk.iaas.model.CreateNicPayload;
+import cloud.stackit.sdk.iaas.model.CreatePublicIPPayload;
+import cloud.stackit.sdk.iaas.model.CreateSecurityGroupPayload;
+import cloud.stackit.sdk.iaas.model.CreateSecurityGroupRulePayload;
+import cloud.stackit.sdk.iaas.model.CreateServerPayload;
+import cloud.stackit.sdk.iaas.model.CreateSnapshotPayload;
+import cloud.stackit.sdk.iaas.model.CreateVolumePayload;
+import cloud.stackit.sdk.iaas.model.GetServerLog200Response;
+import cloud.stackit.sdk.iaas.model.Image;
+import cloud.stackit.sdk.iaas.model.ImageCreateResponse;
+import cloud.stackit.sdk.iaas.model.ImageListResponse;
+import cloud.stackit.sdk.iaas.model.ImageShare;
+import cloud.stackit.sdk.iaas.model.ImageShareConsumer;
+import cloud.stackit.sdk.iaas.model.KeyPairListResponse;
+import cloud.stackit.sdk.iaas.model.Keypair;
+import cloud.stackit.sdk.iaas.model.MachineType;
+import cloud.stackit.sdk.iaas.model.MachineTypeListResponse;
+import cloud.stackit.sdk.iaas.model.NIC;
+import cloud.stackit.sdk.iaas.model.NICListResponse;
+import cloud.stackit.sdk.iaas.model.Network;
+import cloud.stackit.sdk.iaas.model.NetworkArea;
+import cloud.stackit.sdk.iaas.model.NetworkAreaListResponse;
+import cloud.stackit.sdk.iaas.model.NetworkListResponse;
+import cloud.stackit.sdk.iaas.model.NetworkRange;
+import cloud.stackit.sdk.iaas.model.NetworkRangeListResponse;
+import cloud.stackit.sdk.iaas.model.PartialUpdateNetworkAreaPayload;
+import cloud.stackit.sdk.iaas.model.PartialUpdateNetworkPayload;
+import cloud.stackit.sdk.iaas.model.Project;
+import cloud.stackit.sdk.iaas.model.ProjectListResponse;
+import cloud.stackit.sdk.iaas.model.PublicIp;
+import cloud.stackit.sdk.iaas.model.PublicIpListResponse;
+import cloud.stackit.sdk.iaas.model.PublicNetworkListResponse;
+import cloud.stackit.sdk.iaas.model.QuotaListResponse;
+import cloud.stackit.sdk.iaas.model.Request;
+import cloud.stackit.sdk.iaas.model.RescueServerPayload;
+import cloud.stackit.sdk.iaas.model.ResizeServerPayload;
+import cloud.stackit.sdk.iaas.model.ResizeVolumePayload;
+import cloud.stackit.sdk.iaas.model.Route;
+import cloud.stackit.sdk.iaas.model.RouteListResponse;
+import cloud.stackit.sdk.iaas.model.SecurityGroup;
+import cloud.stackit.sdk.iaas.model.SecurityGroupListResponse;
+import cloud.stackit.sdk.iaas.model.SecurityGroupRule;
+import cloud.stackit.sdk.iaas.model.SecurityGroupRuleListResponse;
+import cloud.stackit.sdk.iaas.model.Server;
+import cloud.stackit.sdk.iaas.model.ServerConsoleUrl;
+import cloud.stackit.sdk.iaas.model.ServerListResponse;
+import cloud.stackit.sdk.iaas.model.ServiceAccountMailListResponse;
+import cloud.stackit.sdk.iaas.model.SetImageSharePayload;
+import cloud.stackit.sdk.iaas.model.Snapshot;
+import cloud.stackit.sdk.iaas.model.SnapshotListResponse;
+import cloud.stackit.sdk.iaas.model.UpdateAttachedVolumePayload;
+import cloud.stackit.sdk.iaas.model.UpdateBackupPayload;
+import cloud.stackit.sdk.iaas.model.UpdateImagePayload;
+import cloud.stackit.sdk.iaas.model.UpdateImageSharePayload;
+import cloud.stackit.sdk.iaas.model.UpdateKeyPairPayload;
+import cloud.stackit.sdk.iaas.model.UpdateNetworkAreaRoutePayload;
+import cloud.stackit.sdk.iaas.model.UpdateNicPayload;
+import cloud.stackit.sdk.iaas.model.UpdatePublicIPPayload;
+import cloud.stackit.sdk.iaas.model.UpdateSecurityGroupPayload;
+import cloud.stackit.sdk.iaas.model.UpdateServerPayload;
+import cloud.stackit.sdk.iaas.model.UpdateSnapshotPayload;
+import cloud.stackit.sdk.iaas.model.UpdateVolumePayload;
+import cloud.stackit.sdk.iaas.model.Volume;
+import cloud.stackit.sdk.iaas.model.VolumeAttachment;
+import cloud.stackit.sdk.iaas.model.VolumeAttachmentListResponse;
+import cloud.stackit.sdk.iaas.model.VolumeListResponse;
+import cloud.stackit.sdk.iaas.model.VolumePerformanceClass;
+import cloud.stackit.sdk.iaas.model.VolumePerformanceClassListResponse;
+import com.google.gson.reflect.TypeToken;
+import java.io.IOException;
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+// Package-private access to enforce service-specific API usage (DefaultApi => Api)
+class DefaultApi {
+ private ApiClient localVarApiClient;
+ private int localHostIndex;
+ private String localCustomBaseUrl;
+
+ public DefaultApi() throws IOException {
+ this(new CoreConfiguration());
+ }
+
+ public DefaultApi(CoreConfiguration config) throws IOException {
+ if (config.getCustomEndpoint() != null && !config.getCustomEndpoint().trim().isEmpty()) {
+ localCustomBaseUrl = config.getCustomEndpoint();
+ }
+ this.localVarApiClient = new ApiClient(config);
+ }
+
+ public ApiClient getApiClient() {
+ return localVarApiClient;
+ }
+
+ public void setApiClient(ApiClient apiClient) {
+ this.localVarApiClient = apiClient;
+ }
+
+ public int getHostIndex() {
+ return localHostIndex;
+ }
+
+ public void setHostIndex(int hostIndex) {
+ this.localHostIndex = hostIndex;
+ }
+
+ public String getCustomBaseUrl() {
+ return localCustomBaseUrl;
+ }
+
+ public void setCustomBaseUrl(String customBaseUrl) {
+ this.localCustomBaseUrl = customBaseUrl;
+ }
+
+ /**
+ * Build call for addNetworkToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param networkId The identifier (ID) of a STACKIT Network. (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 | Create and attach network interface was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addNetworkToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID networkId,
+ final ApiCallback _callback)
+ throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] {};
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null) {
+ basePath = localCustomBaseUrl;
+ } else if (localBasePaths.length > 0) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/networks/{networkId}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "networkId" + "}",
+ localVarApiClient.escapeString(networkId.toString()));
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {"application/json"};
+ final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
+ if (localVarAccept != null) {
+ localVarHeaderParams.put("Accept", localVarAccept);
+ }
+
+ final String[] localVarContentTypes = {};
+ final String localVarContentType =
+ localVarApiClient.selectHeaderContentType(localVarContentTypes);
+ if (localVarContentType != null) {
+ localVarHeaderParams.put("Content-Type", localVarContentType);
+ }
+
+ String[] localVarAuthNames = new String[] {};
+ return localVarApiClient.buildCall(
+ basePath,
+ localVarPath,
+ "POST",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addNetworkToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID networkId,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addNetworkToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addNetworkToServer(Async)");
+ }
+
+ // verify the required parameter 'networkId' is set
+ if (networkId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'networkId' when calling addNetworkToServer(Async)");
+ }
+
+ return addNetworkToServerCall(projectId, serverId, networkId, _callback);
+ }
+
+ /**
+ * Create and attach a network interface from the specified network. Create and attach a network
+ * interface from the specified network to the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param networkId The identifier (ID) of a STACKIT Network. (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 | Create and attach network interface was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public void addNetworkToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID networkId)
+ throws ApiException {
+ addNetworkToServerWithHttpInfo(projectId, serverId, networkId);
+ }
+
+ /**
+ * Create and attach a network interface from the specified network. Create and attach a network
+ * interface from the specified network to the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param networkId The identifier (ID) of a STACKIT Network. (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 | Create and attach network interface was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addNetworkToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID networkId)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addNetworkToServerValidateBeforeCall(projectId, serverId, networkId, null);
+ return localVarApiClient.execute(localVarCall);
+ }
+
+ /**
+ * Create and attach a network interface from the specified network. (asynchronously) Create and
+ * attach a network interface from the specified network to the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param networkId The identifier (ID) of a STACKIT Network. (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 | Create and attach network interface was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addNetworkToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID networkId,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addNetworkToServerValidateBeforeCall(projectId, serverId, networkId, _callback);
+ localVarApiClient.executeAsync(localVarCall, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for addNicToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param nicId The identifier (ID) of a network interface. (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 | Network interface attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addNicToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID nicId,
+ final ApiCallback _callback)
+ throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] {};
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null) {
+ basePath = localCustomBaseUrl;
+ } else if (localBasePaths.length > 0) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/nics/{nicId}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "nicId" + "}",
+ localVarApiClient.escapeString(nicId.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,
+ "PUT",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addNicToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID nicId,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addNicToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addNicToServer(Async)");
+ }
+
+ // verify the required parameter 'nicId' is set
+ if (nicId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'nicId' when calling addNicToServer(Async)");
+ }
+
+ return addNicToServerCall(projectId, serverId, nicId, _callback);
+ }
+
+ /**
+ * Attach an existing network interface. Attach an existing network interface to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param nicId The identifier (ID) of a network interface. (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 | Network interface attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public void addNicToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID nicId)
+ throws ApiException {
+ addNicToServerWithHttpInfo(projectId, serverId, nicId);
+ }
+
+ /**
+ * Attach an existing network interface. Attach an existing network interface to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param nicId The identifier (ID) of a network interface. (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 | Network interface attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addNicToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID nicId)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addNicToServerValidateBeforeCall(projectId, serverId, nicId, null);
+ return localVarApiClient.execute(localVarCall);
+ }
+
+ /**
+ * Attach an existing network interface. (asynchronously) Attach an existing network interface
+ * to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param nicId The identifier (ID) of a network interface. (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 | Network interface attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addNicToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID nicId,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addNicToServerValidateBeforeCall(projectId, serverId, nicId, _callback);
+ localVarApiClient.executeAsync(localVarCall, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for addPublicIpToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param publicIpId The identifier (ID) of a Public IP. (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 | Attach Public IP to server was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addPublicIpToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID publicIpId,
+ final ApiCallback _callback)
+ throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] {};
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null) {
+ basePath = localCustomBaseUrl;
+ } else if (localBasePaths.length > 0) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/public-ips/{publicIpId}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "publicIpId" + "}",
+ localVarApiClient.escapeString(publicIpId.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,
+ "PUT",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addPublicIpToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID publicIpId,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addPublicIpToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addPublicIpToServer(Async)");
+ }
+
+ // verify the required parameter 'publicIpId' is set
+ if (publicIpId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'publicIpId' when calling addPublicIpToServer(Async)");
+ }
+
+ return addPublicIpToServerCall(projectId, serverId, publicIpId, _callback);
+ }
+
+ /**
+ * Associate a public IP to the server. Associate a public IP to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param publicIpId The identifier (ID) of a Public IP. (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 | Attach Public IP to server was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public void addPublicIpToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID publicIpId)
+ throws ApiException {
+ addPublicIpToServerWithHttpInfo(projectId, serverId, publicIpId);
+ }
+
+ /**
+ * Associate a public IP to the server. Associate a public IP to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param publicIpId The identifier (ID) of a Public IP. (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 | Attach Public IP to server was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addPublicIpToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID publicIpId)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addPublicIpToServerValidateBeforeCall(projectId, serverId, publicIpId, null);
+ return localVarApiClient.execute(localVarCall);
+ }
+
+ /**
+ * Associate a public IP to the server. (asynchronously) Associate a public IP to a server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param publicIpId The identifier (ID) of a Public IP. (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 | Attach Public IP to server was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addPublicIpToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID publicIpId,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addPublicIpToServerValidateBeforeCall(projectId, serverId, publicIpId, _callback);
+ localVarApiClient.executeAsync(localVarCall, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for addSecurityGroupToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param securityGroupId The identifier (ID) of a STACKIT Security Group. (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 | Security group attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addSecurityGroupToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID securityGroupId,
+ final ApiCallback _callback)
+ throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] {};
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null) {
+ basePath = localCustomBaseUrl;
+ } else if (localBasePaths.length > 0) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/security-groups/{securityGroupId}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "securityGroupId" + "}",
+ localVarApiClient.escapeString(securityGroupId.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,
+ "PUT",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addSecurityGroupToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID securityGroupId,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addSecurityGroupToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addSecurityGroupToServer(Async)");
+ }
+
+ // verify the required parameter 'securityGroupId' is set
+ if (securityGroupId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'securityGroupId' when calling addSecurityGroupToServer(Async)");
+ }
+
+ return addSecurityGroupToServerCall(projectId, serverId, securityGroupId, _callback);
+ }
+
+ /**
+ * Add a server to a security group. Add an existing server to an existing security group.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param securityGroupId The identifier (ID) of a STACKIT Security Group. (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 | Security group attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public void addSecurityGroupToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID securityGroupId)
+ throws ApiException {
+ addSecurityGroupToServerWithHttpInfo(projectId, serverId, securityGroupId);
+ }
+
+ /**
+ * Add a server to a security group. Add an existing server to an existing security group.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param securityGroupId The identifier (ID) of a STACKIT Security Group. (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 | Security group attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addSecurityGroupToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID securityGroupId)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addSecurityGroupToServerValidateBeforeCall(
+ projectId, serverId, securityGroupId, null);
+ return localVarApiClient.execute(localVarCall);
+ }
+
+ /**
+ * Add a server to a security group. (asynchronously) Add an existing server to an existing
+ * security group.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param securityGroupId The identifier (ID) of a STACKIT Security Group. (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 | Security group attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addSecurityGroupToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID securityGroupId,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addSecurityGroupToServerValidateBeforeCall(
+ projectId, serverId, securityGroupId, _callback);
+ localVarApiClient.executeAsync(localVarCall, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for addServiceAccountToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param serviceAccountMail The e-mail address of a service account. (required)
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Service account attached to the server. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addServiceAccountToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull String serviceAccountMail,
+ final ApiCallback _callback)
+ throws ApiException {
+ String basePath = null;
+ // Operation Servers
+ String[] localBasePaths = new String[] {};
+
+ // Determine Base Path to Use
+ if (localCustomBaseUrl != null) {
+ basePath = localCustomBaseUrl;
+ } else if (localBasePaths.length > 0) {
+ basePath = localBasePaths[localHostIndex];
+ } else {
+ basePath = null;
+ }
+
+ Object localVarPostBody = null;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/service-accounts/{serviceAccountMail}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "serviceAccountMail" + "}",
+ localVarApiClient.escapeString(serviceAccountMail.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,
+ "PUT",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addServiceAccountToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull String serviceAccountMail,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addServiceAccountToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addServiceAccountToServer(Async)");
+ }
+
+ // verify the required parameter 'serviceAccountMail' is set
+ if (serviceAccountMail == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serviceAccountMail' when calling addServiceAccountToServer(Async)");
+ }
+
+ return addServiceAccountToServerCall(projectId, serverId, serviceAccountMail, _callback);
+ }
+
+ /**
+ * Attach service account to a server. Attach an additional service account to the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param serviceAccountMail The e-mail address of a service account. (required)
+ * @return ServiceAccountMailListResponse
+ * @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 | Service account attached to the server. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ServiceAccountMailListResponse addServiceAccountToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull String serviceAccountMail)
+ throws ApiException {
+ ApiResponse localVarResp =
+ addServiceAccountToServerWithHttpInfo(projectId, serverId, serviceAccountMail);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Attach service account to a server. Attach an additional service account to the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param serviceAccountMail The e-mail address of a service account. (required)
+ * @return ApiResponse<ServiceAccountMailListResponse>
+ * @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 | Service account attached to the server. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addServiceAccountToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull String serviceAccountMail)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addServiceAccountToServerValidateBeforeCall(
+ projectId, serverId, serviceAccountMail, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Attach service account to a server. (asynchronously) Attach an additional service account to
+ * the server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param serviceAccountMail The e-mail address of a service account. (required)
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body
+ * object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Service account attached to the server. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addServiceAccountToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull String serviceAccountMail,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addServiceAccountToServerValidateBeforeCall(
+ projectId, serverId, serviceAccountMail, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for addVolumeToServer
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param volumeId The identifier (ID) of a STACKIT Volume. (required)
+ * @param addVolumeToServerPayload Request a volume attachment creation. (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 | Volume attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addVolumeToServerCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID volumeId,
+ @javax.annotation.Nullable AddVolumeToServerPayload addVolumeToServerPayload,
+ 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 = addVolumeToServerPayload;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/servers/{serverId}/volume-attachments/{volumeId}"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()))
+ .replace(
+ "{" + "serverId" + "}",
+ localVarApiClient.escapeString(serverId.toString()))
+ .replace(
+ "{" + "volumeId" + "}",
+ localVarApiClient.escapeString(volumeId.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,
+ "PUT",
+ localVarQueryParams,
+ localVarCollectionQueryParams,
+ localVarPostBody,
+ localVarHeaderParams,
+ localVarCookieParams,
+ localVarFormParams,
+ localVarAuthNames,
+ _callback);
+ }
+
+ @SuppressWarnings("rawtypes")
+ private okhttp3.Call addVolumeToServerValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID volumeId,
+ @javax.annotation.Nullable AddVolumeToServerPayload addVolumeToServerPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling addVolumeToServer(Async)");
+ }
+
+ // verify the required parameter 'serverId' is set
+ if (serverId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'serverId' when calling addVolumeToServer(Async)");
+ }
+
+ // verify the required parameter 'volumeId' is set
+ if (volumeId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'volumeId' when calling addVolumeToServer(Async)");
+ }
+
+ return addVolumeToServerCall(
+ projectId, serverId, volumeId, addVolumeToServerPayload, _callback);
+ }
+
+ /**
+ * Attach a volume to a server. Attach an existing volume to an existing server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param volumeId The identifier (ID) of a STACKIT Volume. (required)
+ * @param addVolumeToServerPayload Request a volume attachment creation. (optional)
+ * @return VolumeAttachment
+ * @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 | Volume attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public VolumeAttachment addVolumeToServer(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID volumeId,
+ @javax.annotation.Nullable AddVolumeToServerPayload addVolumeToServerPayload)
+ throws ApiException {
+ ApiResponse localVarResp =
+ addVolumeToServerWithHttpInfo(
+ projectId, serverId, volumeId, addVolumeToServerPayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Attach a volume to a server. Attach an existing volume to an existing server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param volumeId The identifier (ID) of a STACKIT Volume. (required)
+ * @param addVolumeToServerPayload Request a volume attachment creation. (optional)
+ * @return ApiResponse<VolumeAttachment>
+ * @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 | Volume attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse addVolumeToServerWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID volumeId,
+ @javax.annotation.Nullable AddVolumeToServerPayload addVolumeToServerPayload)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ addVolumeToServerValidateBeforeCall(
+ projectId, serverId, volumeId, addVolumeToServerPayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Attach a volume to a server. (asynchronously) Attach an existing volume to an existing
+ * server.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param serverId The identifier (ID) of a STACKIT Server. (required)
+ * @param volumeId The identifier (ID) of a STACKIT Volume. (required)
+ * @param addVolumeToServerPayload Request a volume attachment creation. (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 | Volume attachment request was accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call addVolumeToServerAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull UUID serverId,
+ @javax.annotation.Nonnull UUID volumeId,
+ @javax.annotation.Nullable AddVolumeToServerPayload addVolumeToServerPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ addVolumeToServerValidateBeforeCall(
+ projectId, serverId, volumeId, addVolumeToServerPayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createAffinityGroup
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createAffinityGroupPayload Request a affinity group creation. (required)
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Affinity group was created successfully. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createAffinityGroupCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateAffinityGroupPayload createAffinityGroupPayload,
+ 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 = createAffinityGroupPayload;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/affinity-groups"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()));
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {"application/json"};
+ 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 createAffinityGroupValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateAffinityGroupPayload createAffinityGroupPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling createAffinityGroup(Async)");
+ }
+
+ // verify the required parameter 'createAffinityGroupPayload' is set
+ if (createAffinityGroupPayload == null) {
+ throw new ApiException(
+ "Missing the required parameter 'createAffinityGroupPayload' when calling createAffinityGroup(Async)");
+ }
+
+ return createAffinityGroupCall(projectId, createAffinityGroupPayload, _callback);
+ }
+
+ /**
+ * Create a new affinity group in a project. Create a new server affinity group in the given
+ * project ID.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createAffinityGroupPayload Request a affinity group creation. (required)
+ * @return AffinityGroup
+ * @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 | Affinity group was created successfully. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public AffinityGroup createAffinityGroup(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateAffinityGroupPayload createAffinityGroupPayload)
+ throws ApiException {
+ ApiResponse localVarResp =
+ createAffinityGroupWithHttpInfo(projectId, createAffinityGroupPayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Create a new affinity group in a project. Create a new server affinity group in the given
+ * project ID.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createAffinityGroupPayload Request a affinity group creation. (required)
+ * @return ApiResponse<AffinityGroup>
+ * @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 | Affinity group was created successfully. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse createAffinityGroupWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateAffinityGroupPayload createAffinityGroupPayload)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ createAffinityGroupValidateBeforeCall(projectId, createAffinityGroupPayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Create a new affinity group in a project. (asynchronously) Create a new server affinity group
+ * in the given project ID.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createAffinityGroupPayload Request a affinity group creation. (required)
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body
+ * object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Affinity group was created successfully. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createAffinityGroupAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateAffinityGroupPayload createAffinityGroupPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ createAffinityGroupValidateBeforeCall(
+ projectId, createAffinityGroupPayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createBackup
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createBackupPayload Request a backup creation. (required)
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Create request for Backup accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createBackupCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateBackupPayload createBackupPayload,
+ 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 = createBackupPayload;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/backups"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()));
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {"application/json"};
+ 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 createBackupValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateBackupPayload createBackupPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling createBackup(Async)");
+ }
+
+ // verify the required parameter 'createBackupPayload' is set
+ if (createBackupPayload == null) {
+ throw new ApiException(
+ "Missing the required parameter 'createBackupPayload' when calling createBackup(Async)");
+ }
+
+ return createBackupCall(projectId, createBackupPayload, _callback);
+ }
+
+ /**
+ * Create new Backup. Create a new Backup in a project. If a snapshot ID is provided create the
+ * backup from the snapshot.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createBackupPayload Request a backup creation. (required)
+ * @return Backup
+ * @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 | Create request for Backup accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public Backup createBackup(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateBackupPayload createBackupPayload)
+ throws ApiException {
+ ApiResponse localVarResp = createBackupWithHttpInfo(projectId, createBackupPayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Create new Backup. Create a new Backup in a project. If a snapshot ID is provided create the
+ * backup from the snapshot.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createBackupPayload Request a backup creation. (required)
+ * @return ApiResponse<Backup>
+ * @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 | Create request for Backup accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse createBackupWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateBackupPayload createBackupPayload)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ createBackupValidateBeforeCall(projectId, createBackupPayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Create new Backup. (asynchronously) Create a new Backup in a project. If a snapshot ID is
+ * provided create the backup from the snapshot.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createBackupPayload Request a backup creation. (required)
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body
+ * object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Create request for Backup accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createBackupAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateBackupPayload createBackupPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ createBackupValidateBeforeCall(projectId, createBackupPayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createImage
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createImagePayload Request an image creation. (required)
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Create request for an Image has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 429 | Too Many Requests. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createImageCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateImagePayload createImagePayload,
+ 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 = createImagePayload;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/images"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()));
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {"application/json"};
+ 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 createImageValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateImagePayload createImagePayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling createImage(Async)");
+ }
+
+ // verify the required parameter 'createImagePayload' is set
+ if (createImagePayload == null) {
+ throw new ApiException(
+ "Missing the required parameter 'createImagePayload' when calling createImage(Async)");
+ }
+
+ return createImageCall(projectId, createImagePayload, _callback);
+ }
+
+ /**
+ * Create new Image. Create a new Image in a project. This call, if successful, returns a
+ * pre-signed URL for the customer to upload the image.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createImagePayload Request an image creation. (required)
+ * @return ImageCreateResponse
+ * @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 | Create request for an Image has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 429 | Too Many Requests. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ImageCreateResponse createImage(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateImagePayload createImagePayload)
+ throws ApiException {
+ ApiResponse localVarResp =
+ createImageWithHttpInfo(projectId, createImagePayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Create new Image. Create a new Image in a project. This call, if successful, returns a
+ * pre-signed URL for the customer to upload the image.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createImagePayload Request an image creation. (required)
+ * @return ApiResponse<ImageCreateResponse>
+ * @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 | Create request for an Image has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 429 | Too Many Requests. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse createImageWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateImagePayload createImagePayload)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ createImageValidateBeforeCall(projectId, createImagePayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Create new Image. (asynchronously) Create a new Image in a project. This call, if successful,
+ * returns a pre-signed URL for the customer to upload the image.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createImagePayload Request an image creation. (required)
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body
+ * object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Create request for an Image has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 429 | Too Many Requests. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createImageAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateImagePayload createImagePayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ createImageValidateBeforeCall(projectId, createImagePayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createKeyPair
+ *
+ * @param createKeyPairPayload Request a public key import. (required)
+ * @param _callback Callback for upload/download progress
+ * @return Call to execute
+ * @throws ApiException If fail to serialize the request body object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Import of the public key was successful. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createKeyPairCall(
+ @javax.annotation.Nonnull CreateKeyPairPayload createKeyPairPayload,
+ 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 = createKeyPairPayload;
+
+ // create path and map variables
+ String localVarPath = "/v1/keypairs";
+
+ 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 createKeyPairValidateBeforeCall(
+ @javax.annotation.Nonnull CreateKeyPairPayload createKeyPairPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'createKeyPairPayload' is set
+ if (createKeyPairPayload == null) {
+ throw new ApiException(
+ "Missing the required parameter 'createKeyPairPayload' when calling createKeyPair(Async)");
+ }
+
+ return createKeyPairCall(createKeyPairPayload, _callback);
+ }
+
+ /**
+ * Import a public key. Import a new public key for the requesting user based on provided public
+ * key material. The creation will fail if an SSH keypair with the same name already exists. If
+ * a name is not provided it is autogenerated form the ssh-pubkey comment section. If that is
+ * also not present it will be the the MD5 fingerprint of the key. For autogenerated names
+ * invalid characters will be removed. Supported keypair types are ecdsa, ed25519 and rsa.
+ *
+ * @param createKeyPairPayload Request a public key import. (required)
+ * @return Keypair
+ * @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 | Import of the public key was successful. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public Keypair createKeyPair(
+ @javax.annotation.Nonnull CreateKeyPairPayload createKeyPairPayload)
+ throws ApiException {
+ ApiResponse localVarResp = createKeyPairWithHttpInfo(createKeyPairPayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Import a public key. Import a new public key for the requesting user based on provided public
+ * key material. The creation will fail if an SSH keypair with the same name already exists. If
+ * a name is not provided it is autogenerated form the ssh-pubkey comment section. If that is
+ * also not present it will be the the MD5 fingerprint of the key. For autogenerated names
+ * invalid characters will be removed. Supported keypair types are ecdsa, ed25519 and rsa.
+ *
+ * @param createKeyPairPayload Request a public key import. (required)
+ * @return ApiResponse<Keypair>
+ * @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 | Import of the public key was successful. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse createKeyPairWithHttpInfo(
+ @javax.annotation.Nonnull CreateKeyPairPayload createKeyPairPayload)
+ throws ApiException {
+ okhttp3.Call localVarCall = createKeyPairValidateBeforeCall(createKeyPairPayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Import a public key. (asynchronously) Import a new public key for the requesting user based
+ * on provided public key material. The creation will fail if an SSH keypair with the same name
+ * already exists. If a name is not provided it is autogenerated form the ssh-pubkey comment
+ * section. If that is also not present it will be the the MD5 fingerprint of the key. For
+ * autogenerated names invalid characters will be removed. Supported keypair types are ecdsa,
+ * ed25519 and rsa.
+ *
+ * @param createKeyPairPayload Request a public key import. (required)
+ * @param _callback The callback to be executed when the API call finishes
+ * @return The request call
+ * @throws ApiException If fail to process the API call, e.g. serializing the request body
+ * object
+ * @http.response.details
+ *
+ * Response Details
+ * Status Code | Description | Response Headers |
+ * 201 | Import of the public key was successful. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createKeyPairAsync(
+ @javax.annotation.Nonnull CreateKeyPairPayload createKeyPairPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ createKeyPairValidateBeforeCall(createKeyPairPayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createNetwork
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createNetworkPayload Request a network creation. (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 | Network create has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createNetworkCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateNetworkPayload createNetworkPayload,
+ 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 = createNetworkPayload;
+
+ // create path and map variables
+ String localVarPath =
+ "/v1/projects/{projectId}/networks"
+ .replace(
+ "{" + "projectId" + "}",
+ localVarApiClient.escapeString(projectId.toString()));
+
+ List localVarQueryParams = new ArrayList();
+ List localVarCollectionQueryParams = new ArrayList();
+ Map localVarHeaderParams = new HashMap();
+ Map localVarCookieParams = new HashMap();
+ Map localVarFormParams = new HashMap();
+
+ final String[] localVarAccepts = {"application/json"};
+ 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 createNetworkValidateBeforeCall(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateNetworkPayload createNetworkPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+ // verify the required parameter 'projectId' is set
+ if (projectId == null) {
+ throw new ApiException(
+ "Missing the required parameter 'projectId' when calling createNetwork(Async)");
+ }
+
+ // verify the required parameter 'createNetworkPayload' is set
+ if (createNetworkPayload == null) {
+ throw new ApiException(
+ "Missing the required parameter 'createNetworkPayload' when calling createNetwork(Async)");
+ }
+
+ return createNetworkCall(projectId, createNetworkPayload, _callback);
+ }
+
+ /**
+ * Create new network. Create a new network in a project. `nameservers` will be filled
+ * from `defaultNameservers` of the respective area if not specified. If the project
+ * has `internetAccess` enabled and this is the first network in the project this
+ * might incur cost.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createNetworkPayload Request a network creation. (required)
+ * @return Network
+ * @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 | Network create has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public Network createNetwork(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateNetworkPayload createNetworkPayload)
+ throws ApiException {
+ ApiResponse localVarResp =
+ createNetworkWithHttpInfo(projectId, createNetworkPayload);
+ return localVarResp.getData();
+ }
+
+ /**
+ * Create new network. Create a new network in a project. `nameservers` will be filled
+ * from `defaultNameservers` of the respective area if not specified. If the project
+ * has `internetAccess` enabled and this is the first network in the project this
+ * might incur cost.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createNetworkPayload Request a network creation. (required)
+ * @return ApiResponse<Network>
+ * @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 | Network create has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public ApiResponse createNetworkWithHttpInfo(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateNetworkPayload createNetworkPayload)
+ throws ApiException {
+ okhttp3.Call localVarCall =
+ createNetworkValidateBeforeCall(projectId, createNetworkPayload, null);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ return localVarApiClient.execute(localVarCall, localVarReturnType);
+ }
+
+ /**
+ * Create new network. (asynchronously) Create a new network in a project.
+ * `nameservers` will be filled from `defaultNameservers` of the respective
+ * area if not specified. If the project has `internetAccess` enabled and this is the
+ * first network in the project this might incur cost.
+ *
+ * @param projectId The identifier (ID) of a STACKIT Project. (required)
+ * @param createNetworkPayload Request a network creation. (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 | Network create has been accepted. | - |
+ * 400 | A bad request. | - |
+ * 401 | A request which was not authorized. | - |
+ * 403 | A request which was forbidden. | - |
+ * 404 | The object was not found. | - |
+ * 409 | A conflict has occurred. | - |
+ * 500 | Internal Server Error, returns a 500 if something is broken on IaaS API Side. | - |
+ *
+ */
+ public okhttp3.Call createNetworkAsync(
+ @javax.annotation.Nonnull UUID projectId,
+ @javax.annotation.Nonnull CreateNetworkPayload createNetworkPayload,
+ final ApiCallback _callback)
+ throws ApiException {
+
+ okhttp3.Call localVarCall =
+ createNetworkValidateBeforeCall(projectId, createNetworkPayload, _callback);
+ Type localVarReturnType = new TypeToken() {}.getType();
+ localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
+ return localVarCall;
+ }
+
+ /**
+ * Build call for createNetworkArea
+ *
+ * @param organizationId The identifier (ID) of a STACKIT Organization. (required)
+ * @param createNetworkAreaPayload Request an area creation. (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
+ *