diff --git a/services/loadbalancer/README.md b/services/loadbalancer/README.md new file mode 100644 index 0000000..99eb5af --- /dev/null +++ b/services/loadbalancer/README.md @@ -0,0 +1,87 @@ +# STACKIT Java SDK for STACKIT Load Balancer API + +- API version: 2.0.0 + +This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. + +For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + + +This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK. + +## Installation from Maven Central (recommended) + +The release artifacts for this SDK submodule are available on [Maven Central](https://central.sonatype.com/artifact/cloud.stackit.sdk/loadbalancer). + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + loadbalancer + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenCentral() + } + + dependencies { + implementation "cloud.stackit.sdk:loadbalancer:" + } +``` + +## Installation from local build + +Building the API client library requires: +1. Java SDK (version 11 to 21 should be supported) installed on your system + +To install the API client library to your local Maven repository, simply execute: + +```shell +./gradlew services:loadbalancer:publishToMavenLocal +``` + +### Maven users + +Add this dependency to your project's POM: + +```xml + + cloud.stackit.sdk + loadbalancer + + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy + repositories { + mavenLocal() + } + + dependencies { + implementation "cloud.stackit.sdk:loadbalancer:" + } +``` + +## Getting Started + +See the [loadbalancer examples](https://github.com/stackitcloud/stackit-sdk-java/tree/main/examples/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/examples). + +## Recommendation + +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. diff --git a/services/loadbalancer/build.gradle b/services/loadbalancer/build.gradle new file mode 100644 index 0000000..10cd648 --- /dev/null +++ b/services/loadbalancer/build.gradle @@ -0,0 +1,19 @@ + +ext { + jakarta_annotation_version = "1.3.5" +} + +dependencies { + implementation "com.google.code.findbugs:jsr305:3.0.2" + implementation 'com.squareup.okhttp3:okhttp:4.12.0' + implementation 'com.squareup.okhttp3:logging-interceptor:4.12.0' + implementation 'com.google.code.gson:gson:2.9.1' + implementation 'io.gsonfire:gson-fire:1.9.0' + implementation 'jakarta.ws.rs:jakarta.ws.rs-api:2.1.6' + implementation 'org.openapitools:jackson-databind-nullable:0.2.6' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.17.0' + implementation "jakarta.annotation:jakarta.annotation-api:$jakarta_annotation_version" + testImplementation 'org.junit.jupiter:junit-jupiter-api:5.10.3' + testImplementation 'org.mockito:mockito-core:3.12.4' + testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.10.3' +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiCallback.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiCallback.java new file mode 100644 index 0000000..ec847b6 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiCallback.java @@ -0,0 +1,60 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +import cloud.stackit.sdk.core.exception.ApiException; +import java.util.List; +import java.util.Map; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiClient.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiClient.java new file mode 100644 index 0000000..9e9cd4c --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiClient.java @@ -0,0 +1,1548 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.net.ssl.*; +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +/** ApiClient class. */ +public class ApiClient { + + protected String basePath = "https://load-balancer.api.stackit.cloud"; + protected List servers = + new ArrayList( + Arrays.asList( + new ServerConfiguration( + "https://load-balancer.api.stackit.cloud", + "No description provided", + new HashMap() { + { + put( + "region", + new ServerVariable( + "No description provided", + "global", + new HashSet())); + } + }))); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + protected boolean debugging = false; + protected Map defaultHeaderMap = new HashMap(); + protected Map defaultCookieMap = new HashMap(); + protected String tempFolderPath = null; + + protected DateFormat dateFormat; + protected DateFormat datetimeFormat; + protected boolean lenientDatetimeFormat; + protected int dateLength; + + protected InputStream sslCaCert; + protected boolean verifyingSsl; + protected KeyManager[] keyManagers; + + protected OkHttpClient httpClient; + protected JSON json; + + protected HttpLoggingInterceptor loggingInterceptor; + + protected CoreConfiguration configuration; + + /** + * Basic constructor for ApiClient. + * + *

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

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

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

Note that the values of each of the returned Pair objects are percent-encoded. + * + * @param collectionFormat The collection format of the parameter. + * @param name The name of the parameter. + * @param value The value of the parameter. + * @return A list of {@code Pair} objects. + */ + public List parameterToPairs(String collectionFormat, String name, Collection value) { + List params = new ArrayList(); + + // preconditions + if (name == null || name.isEmpty() || value == null || value.isEmpty()) { + return params; + } + + // create the params based on the collection format + if ("multi".equals(collectionFormat)) { + for (Object item : value) { + params.add(new Pair(name, escapeString(parameterToString(item)))); + } + return params; + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + // escape all delimiters except commas, which are URI reserved + // characters + if ("ssv".equals(collectionFormat)) { + delimiter = escapeString(" "); + } else if ("tsv".equals(collectionFormat)) { + delimiter = escapeString("\t"); + } else if ("pipes".equals(collectionFormat)) { + delimiter = escapeString("|"); + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(escapeString(parameterToString(item))); + } + + params.add(new Pair(name, sb.substring(delimiter.length()))); + + return params; + } + + /** + * Formats the specified free-form query parameters to a list of {@code Pair} objects. + * + * @param value The free-form query parameters. + * @return A list of {@code Pair} objects. + */ + public List freeFormParameterToPairs(Object value) { + List params = new ArrayList<>(); + + // preconditions + if (value == null || !(value instanceof Map)) { + return params; + } + + @SuppressWarnings("unchecked") + final Map valuesMap = (Map) value; + + for (Map.Entry entry : valuesMap.entrySet()) { + params.add(new Pair(entry.getKey(), parameterToString(entry.getValue()))); + } + + return params; + } + + /** + * Formats the specified collection path parameter to a string value. + * + * @param collectionFormat The collection format of the parameter. + * @param value The value of the parameter. + * @return String representation of the parameter + */ + public String collectionPathParameterToString(String collectionFormat, Collection value) { + // create the value based on the collection format + if ("multi".equals(collectionFormat)) { + // not valid for path params + return parameterToString(value); + } + + // collectionFormat is assumed to be "csv" by default + String delimiter = ","; + + if ("ssv".equals(collectionFormat)) { + delimiter = " "; + } else if ("tsv".equals(collectionFormat)) { + delimiter = "\t"; + } else if ("pipes".equals(collectionFormat)) { + delimiter = "|"; + } + + StringBuilder sb = new StringBuilder(); + for (Object item : value) { + sb.append(delimiter); + sb.append(parameterToString(item)); + } + + return sb.substring(delimiter.length()); + } + + /** + * Sanitize filename by removing path. e.g. ../../sun.gif becomes sun.gif + * + * @param filename The filename to be sanitized + * @return The sanitized filename + */ + public String sanitizeFilename(String filename) { + return filename.replaceFirst("^.*[/\\\\]", ""); + } + + /** + * Check if the given MIME is a JSON MIME. JSON MIME examples: application/json + * application/json; charset=UTF8 APPLICATION/JSON application/vnd.company+json "* / *" is also + * default to JSON + * + * @param mime MIME (Multipurpose Internet Mail Extensions) + * @return True if the given MIME is JSON, false otherwise. + */ + public boolean isJsonMime(String mime) { + String jsonMime = "(?i)^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$"; + return mime != null && (mime.matches(jsonMime) || mime.equals("*/*")); + } + + /** + * Select the Accept header's value from the given accepts array: if JSON exists in the given + * array, use it; otherwise use all of them (joining into a string) + * + * @param accepts The accepts array to select from + * @return The Accept header to use. If the given array is empty, null will be returned (not to + * set the Accept header explicitly). + */ + public String selectHeaderAccept(String[] accepts) { + if (accepts.length == 0) { + return null; + } + for (String accept : accepts) { + if (isJsonMime(accept)) { + return accept; + } + } + return StringUtil.join(accepts, ","); + } + + /** + * Select the Content-Type header's value from the given array: if JSON exists in the given + * array, use it; otherwise use the first one of the array. + * + * @param contentTypes The Content-Type array to select from + * @return The Content-Type header to use. If the given array is empty, returns null. If it + * matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0) { + return null; + } + + if (contentTypes[0].equals("*/*")) { + return "application/json"; + } + + for (String contentType : contentTypes) { + if (isJsonMime(contentType)) { + return contentType; + } + } + + return contentTypes[0]; + } + + /** + * Escape the given string to be used as URL query value. + * + * @param str String to be escaped + * @return Escaped string + */ + public String escapeString(String str) { + try { + return URLEncoder.encode(str, "utf8").replaceAll("\\+", "%20"); + } catch (UnsupportedEncodingException e) { + return str; + } + } + + /** + * Deserialize response body to Java object, according to the return type and the Content-Type + * response header. + * + * @param Type + * @param response HTTP response + * @param returnType The type of the Java object + * @return The deserialized Java object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to deserialize response body, + * i.e. cannot read response body or the Content-Type of the response is not supported. + */ + @SuppressWarnings("unchecked") + public T deserialize(Response response, Type returnType) throws ApiException { + if (response == null || returnType == null) { + return null; + } + + if ("byte[]".equals(returnType.toString())) { + // Handle binary response (byte array). + try { + return (T) response.body().bytes(); + } catch (IOException e) { + throw new ApiException(e); + } + } else if (returnType.equals(File.class)) { + // Handle file downloading. + return (T) downloadFileFromResponse(response); + } + + ResponseBody respBody = response.body(); + if (respBody == null) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + try { + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody.byteStream(), returnType); + } else if (returnType.equals(String.class)) { + String respBodyString = respBody.string(); + if (respBodyString.isEmpty()) { + return null; + } + // Expecting string, return the raw response body. + return (T) respBodyString; + } else { + throw new ApiException( + "Content type \"" + + contentType + + "\" is not supported for type: " + + returnType, + response.code(), + response.headers().toMultimap(), + response.body().string()); + } + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Serialize the given Java object into request body according to the object's class and the + * request Content-Type. + * + * @param obj The Java object + * @param contentType The request Content-Type + * @return The serialized request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the given object + */ + public RequestBody serialize(Object obj, String contentType) throws ApiException { + if (obj instanceof byte[]) { + // Binary (byte array) body parameter support. + return RequestBody.create((byte[]) obj, MediaType.parse(contentType)); + } else if (obj instanceof File) { + // File body parameter support. + return RequestBody.create((File) obj, MediaType.parse(contentType)); + } else if ("text/plain".equals(contentType) && obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else if (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else if (obj instanceof String) { + return RequestBody.create((String) obj, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * Download file from the given response. + * + * @param response An instance of the Response object + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to read file content from + * response and write to disk + * @return Downloaded file + */ + public File downloadFileFromResponse(Response response) throws ApiException { + try { + File file = prepareDownloadFile(response); + BufferedSink sink = Okio.buffer(Okio.sink(file)); + sink.writeAll(response.body().source()); + sink.close(); + return file; + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * Prepare file for download + * + * @param response An instance of the Response object + * @return Prepared file for the download + * @throws java.io.IOException If fail to prepare file for download + */ + public File prepareDownloadFile(Response response) throws IOException { + String filename = null; + String contentDisposition = response.header("Content-Disposition"); + if (contentDisposition != null && !"".equals(contentDisposition)) { + // Get filename from the Content-Disposition header. + Pattern pattern = Pattern.compile("filename=['\"]?([^'\"\\s]+)['\"]?"); + Matcher matcher = pattern.matcher(contentDisposition); + if (matcher.find()) { + filename = sanitizeFilename(matcher.group(1)); + } + } + + String prefix = null; + String suffix = null; + if (filename == null) { + prefix = "download-"; + suffix = ""; + } else { + int pos = filename.lastIndexOf("."); + if (pos == -1) { + prefix = filename + "-"; + } else { + prefix = filename.substring(0, pos) + "-"; + suffix = filename.substring(pos); + } + // Files.createTempFile requires the prefix to be at least three characters long + if (prefix.length() < 3) prefix = "download-"; + } + + if (tempFolderPath == null) return Files.createTempFile(prefix, suffix).toFile(); + else return Files.createTempFile(Paths.get(tempFolderPath), prefix, suffix).toFile(); + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call) throws ApiException { + return execute(call, null); + } + + /** + * Execute HTTP call and deserialize the HTTP response body into the given return type. + * + * @param returnType The return type used to deserialize HTTP response body + * @param The return type corresponding to (same with) returnType + * @param call Call + * @return ApiResponse object containing response status, headers and data, which is a Java + * object deserialized from response body and would be null when returnType is null. + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to execute the call + */ + public ApiResponse execute(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + T data = handleResponse(response, returnType); + return new ApiResponse(response.code(), response.headers().toMultimap(), data); + } catch (IOException e) { + throw new ApiException(e); + } + } + + /** + * {@link #executeAsync(Call, Type, ApiCallback)} + * + * @param Type + * @param call An instance of the Call object + * @param callback ApiCallback<T> + */ + public void executeAsync(Call call, ApiCallback callback) { + executeAsync(call, null, callback); + } + + /** + * Execute HTTP call asynchronously. + * + * @param Type + * @param call The callback to be executed when the API call finishes + * @param returnType Return type + * @param callback ApiCallback + * @see #execute(Call, Type) + */ + @SuppressWarnings("unchecked") + public void executeAsync(Call call, final Type returnType, final ApiCallback callback) { + call.enqueue( + new Callback() { + @Override + public void onFailure(Call call, IOException e) { + callback.onFailure(new ApiException(e), 0, null); + } + + @Override + public void onResponse(Call call, Response response) throws IOException { + T result; + try { + result = (T) handleResponse(response, returnType); + } catch (ApiException e) { + callback.onFailure(e, response.code(), response.headers().toMultimap()); + return; + } catch (Exception e) { + callback.onFailure( + new ApiException(e), + response.code(), + response.headers().toMultimap()); + return; + } + callback.onSuccess( + result, response.code(), response.headers().toMultimap()); + } + }); + } + + /** + * Handle the given response, return the deserialized object when the response is successful. + * + * @param Type + * @param response Response + * @param returnType Return type + * @return Type + * @throws cloud.stackit.sdk.core.exception.ApiException If the response has an unsuccessful + * status code or fail to deserialize the response body + */ + public T handleResponse(Response response, Type returnType) throws ApiException { + if (response.isSuccessful()) { + if (returnType == null || response.code() == 204) { + // returning null if the returnType is not defined, + // or the status code is 204 (No Content) + if (response.body() != null) { + try { + response.body().close(); + } catch (Exception e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + return null; + } else { + return deserialize(response, returnType); + } + } else { + String respBody = null; + if (response.body() != null) { + try { + respBody = response.body().string(); + } catch (IOException e) { + throw new ApiException( + response.message(), + e, + response.code(), + response.headers().toMultimap()); + } + } + throw new ApiException( + response.message(), response.code(), response.headers().toMultimap(), respBody); + } + } + + /** + * Build HTTP call with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP call + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Call buildCall( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + Request request = + buildRequest( + baseUrl, + path, + method, + queryParams, + collectionQueryParams, + body, + headerParams, + cookieParams, + formParams, + authNames, + callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @param baseUrl The base URL + * @param path The sub-path of the HTTP URL + * @param method The request method, one of "GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH" and + * "DELETE" + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @param body The request body object + * @param headerParams The header parameters + * @param cookieParams The cookie parameters + * @param formParams The form parameters + * @param authNames The authentications to apply + * @param callback Callback for upload/download progress + * @return The HTTP request + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object + */ + public Request buildRequest( + String baseUrl, + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback) + throws ApiException { + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + String contentTypePure = contentType; + if (contentTypePure != null && contentTypePure.contains(";")) { + contentTypePure = contentType.substring(0, contentType.indexOf(";")); + } + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentTypePure)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentTypePure)) { + reqBody = buildRequestBodyMultipart(formParams); + } else if (body == null) { + if ("DELETE".equals(method)) { + // allow calling DELETE without sending a request body + reqBody = null; + } else { + // use an empty request body (for POST, PUT and PATCH) + reqBody = + RequestBody.create( + "", contentType == null ? null : MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + List updatedQueryParams = new ArrayList<>(queryParams); + + final Request.Builder reqBuilder = + new Request.Builder() + .url(buildUrl(baseUrl, path, updatedQueryParams, collectionQueryParams)); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl( + String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException( + String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", + serverIndex, servers.size())); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())) + .append("=") + .append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader( + "Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader( + "Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, which could + * contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item : list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, File file) { + Headers partHeaders = + Headers.of( + "Content-Disposition", + "form-data; name=\"" + key + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } + + /** + * Add a Content-Disposition Header for the given key and complex object to the MultipartBody + * Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param obj The complex object to add to the Header + */ + protected void addPartToMultiPartBuilder( + MultipartBody.Builder mpBuilder, String key, Object obj) { + RequestBody requestBody; + if (obj instanceof String) { + requestBody = RequestBody.create((String) obj, MediaType.parse("text/plain")); + } else { + String content; + if (obj != null) { + content = JSON.serialize(obj); + } else { + content = null; + } + requestBody = RequestBody.create(content, MediaType.parse("application/json")); + } + + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + key + "\""); + mpBuilder.addPart(partHeaders, requestBody); + } + + /** + * Get network interceptor to add it to the httpClient to track download progress for async + * requests. + */ + protected Interceptor getProgressInterceptor() { + return new Interceptor() { + @Override + public Response intercept(Interceptor.Chain chain) throws IOException { + final Request request = chain.request(); + final Response originalResponse = chain.proceed(request); + if (request.tag() instanceof ApiCallback) { + final ApiCallback callback = (ApiCallback) request.tag(); + return originalResponse + .newBuilder() + .body(new ProgressResponseBody(originalResponse.body(), callback)) + .build(); + } + return originalResponse; + } + }; + } + + /** + * Apply SSL related settings to httpClient according to the current values of verifyingSsl and + * sslCaCert. + */ + protected void applySslSettings() { + try { + TrustManager[] trustManagers; + HostnameVerifier hostnameVerifier; + if (!verifyingSsl) { + trustManagers = + new TrustManager[] { + new X509TrustManager() { + @Override + public void checkClientTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public void checkServerTrusted( + java.security.cert.X509Certificate[] chain, String authType) + throws CertificateException {} + + @Override + public java.security.cert.X509Certificate[] getAcceptedIssuers() { + return new java.security.cert.X509Certificate[] {}; + } + } + }; + hostnameVerifier = + new HostnameVerifier() { + @Override + public boolean verify(String hostname, SSLSession session) { + return true; + } + }; + } else { + TrustManagerFactory trustManagerFactory = + TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm()); + + if (sslCaCert == null) { + trustManagerFactory.init((KeyStore) null); + } else { + char[] password = null; // Any password will work. + CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509"); + Collection certificates = + certificateFactory.generateCertificates(sslCaCert); + if (certificates.isEmpty()) { + throw new IllegalArgumentException( + "expected non-empty set of trusted certificates"); + } + KeyStore caKeyStore = newEmptyKeyStore(password); + int index = 0; + for (Certificate certificate : certificates) { + String certificateAlias = "ca" + (index++); + caKeyStore.setCertificateEntry(certificateAlias, certificate); + } + trustManagerFactory.init(caKeyStore); + } + trustManagers = trustManagerFactory.getTrustManagers(); + hostnameVerifier = OkHostnameVerifier.INSTANCE; + } + + SSLContext sslContext = SSLContext.getInstance("TLS"); + sslContext.init(keyManagers, trustManagers, new SecureRandom()); + httpClient = + httpClient + .newBuilder() + .sslSocketFactory( + sslContext.getSocketFactory(), + (X509TrustManager) trustManagers[0]) + .hostnameVerifier(hostnameVerifier) + .build(); + } catch (GeneralSecurityException e) { + throw new RuntimeException(e); + } + } + + protected KeyStore newEmptyKeyStore(char[] password) throws GeneralSecurityException { + try { + KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType()); + keyStore.load(null, password); + return keyStore; + } catch (IOException e) { + throw new AssertionError(e); + } + } + + /** + * Convert the HTTP request body to a string. + * + * @param requestBody The HTTP request object + * @return The string representation of the HTTP request body + * @throws cloud.stackit.sdk.core.exception.ApiException If fail to serialize the request body + * object into a string + */ + protected String requestBodyToString(RequestBody requestBody) throws ApiException { + if (requestBody != null) { + try { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return buffer.readUtf8(); + } catch (final IOException e) { + throw new ApiException(e); + } + } + + // empty http request body + return ""; + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiResponse.java new file mode 100644 index 0000000..7f0c13c --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ApiResponse.java @@ -0,0 +1,73 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/GzipRequestInterceptor.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/GzipRequestInterceptor.java new file mode 100644 index 0000000..ca93930 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/GzipRequestInterceptor.java @@ -0,0 +1,87 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/JSON.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/JSON.java new file mode 100644 index 0000000..9f009fc --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/JSON.java @@ -0,0 +1,510 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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.loadbalancer.model.ActiveHealthCheck + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.CreateCredentialsPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.CreateCredentialsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.CreateLoadBalancerPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.CredentialsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.GetCredentialsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.GetQuotaResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.GoogleProtobufAny + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.ListCredentialsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.ListLoadBalancersResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.ListPlansResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.Listener.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadBalancer.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadBalancerError + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadBalancerOptions + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadbalancerOptionAccessControl + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadbalancerOptionLogs + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadbalancerOptionMetrics + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.LoadbalancerOptionObservability + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.Network.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.OptionsTCP.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.OptionsUDP.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.PlanDetails.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.SecurityGroup.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.ServerNameIndicator + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.SessionPersistence + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.Status.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.Target.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.TargetPool.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.UpdateCredentialsPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.UpdateCredentialsResponse + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.UpdateLoadBalancerPayload + .CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory( + new cloud.stackit.sdk.loadbalancer.model.UpdateTargetPoolPayload + .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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/Pair.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/Pair.java new file mode 100644 index 0000000..66ec5e1 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/Pair.java @@ -0,0 +1,38 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +@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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressRequestBody.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressRequestBody.java new file mode 100644 index 0000000..ef39899 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressRequestBody.java @@ -0,0 +1,71 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressResponseBody.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressResponseBody.java new file mode 100644 index 0000000..fae73f3 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ProgressResponseBody.java @@ -0,0 +1,68 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerConfiguration.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerConfiguration.java new file mode 100644 index 0000000..0585459 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerConfiguration.java @@ -0,0 +1,79 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerVariable.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerVariable.java new file mode 100644 index 0000000..6dd3f15 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/ServerVariable.java @@ -0,0 +1,37 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/StringUtil.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/StringUtil.java new file mode 100644 index 0000000..2fbfcb8 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/StringUtil.java @@ -0,0 +1,83 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +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/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/DefaultApi.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/DefaultApi.java new file mode 100644 index 0000000..073ce20 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/DefaultApi.java @@ -0,0 +1,3056 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.exception.ApiException; +import cloud.stackit.sdk.loadbalancer.ApiCallback; +import cloud.stackit.sdk.loadbalancer.ApiClient; +import cloud.stackit.sdk.loadbalancer.ApiResponse; +import cloud.stackit.sdk.loadbalancer.Pair; +import cloud.stackit.sdk.loadbalancer.model.CreateCredentialsPayload; +import cloud.stackit.sdk.loadbalancer.model.CreateCredentialsResponse; +import cloud.stackit.sdk.loadbalancer.model.CreateLoadBalancerPayload; +import cloud.stackit.sdk.loadbalancer.model.GetCredentialsResponse; +import cloud.stackit.sdk.loadbalancer.model.GetQuotaResponse; +import cloud.stackit.sdk.loadbalancer.model.ListCredentialsResponse; +import cloud.stackit.sdk.loadbalancer.model.ListLoadBalancersResponse; +import cloud.stackit.sdk.loadbalancer.model.ListPlansResponse; +import cloud.stackit.sdk.loadbalancer.model.LoadBalancer; +import cloud.stackit.sdk.loadbalancer.model.TargetPool; +import cloud.stackit.sdk.loadbalancer.model.UpdateCredentialsPayload; +import cloud.stackit.sdk.loadbalancer.model.UpdateCredentialsResponse; +import cloud.stackit.sdk.loadbalancer.model.UpdateLoadBalancerPayload; +import cloud.stackit.sdk.loadbalancer.model.UpdateTargetPoolPayload; +import com.google.gson.reflect.TypeToken; +import java.io.IOException; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import okhttp3.OkHttpClient; + +// Package-private access to enforce service-specific API usage (DefaultApi => Api) +class DefaultApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + /** + * Basic constructor for DefaultApi + * + *

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

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public DefaultApi(CoreConfiguration config) throws IOException { + this(null, config); + } + + /** + * Constructor for DefaultApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public DefaultApi(OkHttpClient httpClient) throws IOException { + this(httpClient, new CoreConfiguration()); + } + + /** + * Constructor for DefaultApi + * + * @param httpClient OkHttpClient object + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public DefaultApi(OkHttpClient httpClient, CoreConfiguration config) throws IOException { + if (config.getCustomEndpoint() != null && !config.getCustomEndpoint().trim().isEmpty()) { + localCustomBaseUrl = config.getCustomEndpoint(); + } + this.localVarApiClient = new ApiClient(httpClient, config); + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createCredentials + * + * @param projectId (required) + * @param region (required) + * @param createCredentialsPayload (required) + * @param xRequestID (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call createCredentialsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateCredentialsPayload createCredentialsPayload, + @javax.annotation.Nullable UUID xRequestID, + 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 = createCredentialsPayload; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/credentials" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + if (xRequestID != null) { + localVarHeaderParams.put( + "X-Request-ID", localVarApiClient.parameterToString(xRequestID)); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createCredentialsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateCredentialsPayload createCredentialsPayload, + @javax.annotation.Nullable UUID xRequestID, + 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 createCredentials(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createCredentials(Async)"); + } + + // verify the required parameter 'createCredentialsPayload' is set + if (createCredentialsPayload == null) { + throw new ApiException( + "Missing the required parameter 'createCredentialsPayload' when calling createCredentials(Async)"); + } + + return createCredentialsCall( + projectId, region, createCredentialsPayload, xRequestID, _callback); + } + + /** + * Create credentials for observability of the Load Balancer Created credentials can be stored + * and used for the load balancer observability. For example, when using STACKIT Observability, + * credentials first must be created for that STACKIT Observability instance (by using their API + * or the STACKIT Portal) and then can be provided to the load balancer by storing them with + * this endpoint. + * + * @param projectId (required) + * @param region (required) + * @param createCredentialsPayload (required) + * @param xRequestID (optional) + * @return CreateCredentialsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public CreateCredentialsResponse createCredentials( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateCredentialsPayload createCredentialsPayload, + @javax.annotation.Nullable UUID xRequestID) + throws ApiException { + ApiResponse localVarResp = + createCredentialsWithHttpInfo( + projectId, region, createCredentialsPayload, xRequestID); + return localVarResp.getData(); + } + + /** + * Create credentials for observability of the Load Balancer Created credentials can be stored + * and used for the load balancer observability. For example, when using STACKIT Observability, + * credentials first must be created for that STACKIT Observability instance (by using their API + * or the STACKIT Portal) and then can be provided to the load balancer by storing them with + * this endpoint. + * + * @param projectId (required) + * @param region (required) + * @param createCredentialsPayload (required) + * @param xRequestID (optional) + * @return ApiResponse<CreateCredentialsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse createCredentialsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateCredentialsPayload createCredentialsPayload, + @javax.annotation.Nullable UUID xRequestID) + throws ApiException { + okhttp3.Call localVarCall = + createCredentialsValidateBeforeCall( + projectId, region, createCredentialsPayload, xRequestID, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create credentials for observability of the Load Balancer (asynchronously) Created + * credentials can be stored and used for the load balancer observability. For example, when + * using STACKIT Observability, credentials first must be created for that STACKIT Observability + * instance (by using their API or the STACKIT Portal) and then can be provided to the load + * balancer by storing them with this endpoint. + * + * @param projectId (required) + * @param region (required) + * @param createCredentialsPayload (required) + * @param xRequestID (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call createCredentialsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateCredentialsPayload createCredentialsPayload, + @javax.annotation.Nullable UUID xRequestID, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createCredentialsValidateBeforeCall( + projectId, region, createCredentialsPayload, xRequestID, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for createLoadBalancer + * + * @param projectId (required) + * @param region (required) + * @param createLoadBalancerPayload (required) + * @param xRequestID (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 load balancer already exists -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call createLoadBalancerCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateLoadBalancerPayload createLoadBalancerPayload, + @javax.annotation.Nullable UUID xRequestID, + 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 = createLoadBalancerPayload; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + if (xRequestID != null) { + localVarHeaderParams.put( + "X-Request-ID", localVarApiClient.parameterToString(xRequestID)); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createLoadBalancerValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateLoadBalancerPayload createLoadBalancerPayload, + @javax.annotation.Nullable UUID xRequestID, + 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 createLoadBalancer(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling createLoadBalancer(Async)"); + } + + // verify the required parameter 'createLoadBalancerPayload' is set + if (createLoadBalancerPayload == null) { + throw new ApiException( + "Missing the required parameter 'createLoadBalancerPayload' when calling createLoadBalancer(Async)"); + } + + return createLoadBalancerCall( + projectId, region, createLoadBalancerPayload, xRequestID, _callback); + } + + /** + * Create a load balancer in a project Create Load Balancer will create a load balancer. The + * default load balancing algorithm is round robin unless useSourceIpAddress in session + * persistence is enabled for a target pool then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param createLoadBalancerPayload (required) + * @param xRequestID (optional) + * @return LoadBalancer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 load balancer already exists -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public LoadBalancer createLoadBalancer( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateLoadBalancerPayload createLoadBalancerPayload, + @javax.annotation.Nullable UUID xRequestID) + throws ApiException { + ApiResponse localVarResp = + createLoadBalancerWithHttpInfo( + projectId, region, createLoadBalancerPayload, xRequestID); + return localVarResp.getData(); + } + + /** + * Create a load balancer in a project Create Load Balancer will create a load balancer. The + * default load balancing algorithm is round robin unless useSourceIpAddress in session + * persistence is enabled for a target pool then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param createLoadBalancerPayload (required) + * @param xRequestID (optional) + * @return ApiResponse<LoadBalancer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 load balancer already exists -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse createLoadBalancerWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateLoadBalancerPayload createLoadBalancerPayload, + @javax.annotation.Nullable UUID xRequestID) + throws ApiException { + okhttp3.Call localVarCall = + createLoadBalancerValidateBeforeCall( + projectId, region, createLoadBalancerPayload, xRequestID, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create a load balancer in a project (asynchronously) Create Load Balancer will create a load + * balancer. The default load balancing algorithm is round robin unless useSourceIpAddress in + * session persistence is enabled for a target pool then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param createLoadBalancerPayload (required) + * @param xRequestID (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 load balancer already exists -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call createLoadBalancerAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull CreateLoadBalancerPayload createLoadBalancerPayload, + @javax.annotation.Nullable UUID xRequestID, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + createLoadBalancerValidateBeforeCall( + projectId, region, createLoadBalancerPayload, xRequestID, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteCredentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call deleteCredentialsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "credentialsRef" + "}", + localVarApiClient.escapeString(credentialsRef.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteCredentialsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + 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 deleteCredentials(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteCredentials(Async)"); + } + + // verify the required parameter 'credentialsRef' is set + if (credentialsRef == null) { + throw new ApiException( + "Missing the required parameter 'credentialsRef' when calling deleteCredentials(Async)"); + } + + return deleteCredentialsCall(projectId, region, credentialsRef, _callback); + } + + /** + * Delete a single credential in a project. Delete Credential + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public Object deleteCredentials( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef) + throws ApiException { + ApiResponse localVarResp = + deleteCredentialsWithHttpInfo(projectId, region, credentialsRef); + return localVarResp.getData(); + } + + /** + * Delete a single credential in a project. Delete Credential + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @return ApiResponse<Object> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse deleteCredentialsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef) + throws ApiException { + okhttp3.Call localVarCall = + deleteCredentialsValidateBeforeCall(projectId, region, credentialsRef, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete a single credential in a project. (asynchronously) Delete Credential + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call deleteCredentialsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteCredentialsValidateBeforeCall(projectId, region, credentialsRef, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteLoadBalancer + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call deleteLoadBalancerCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers/{name}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "name" + "}", + localVarApiClient.escapeString(name.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteLoadBalancerValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + 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 deleteLoadBalancer(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling deleteLoadBalancer(Async)"); + } + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException( + "Missing the required parameter 'name' when calling deleteLoadBalancer(Async)"); + } + + return deleteLoadBalancerCall(projectId, region, name, _callback); + } + + /** + * Delete a given load balancer in a project. DeleteLoadBalancer will delete a given load + * balancer. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @return Object + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public Object deleteLoadBalancer( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name) + throws ApiException { + ApiResponse localVarResp = deleteLoadBalancerWithHttpInfo(projectId, region, name); + return localVarResp.getData(); + } + + /** + * Delete a given load balancer in a project. DeleteLoadBalancer will delete a given load + * balancer. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @return ApiResponse<Object> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse deleteLoadBalancerWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name) + throws ApiException { + okhttp3.Call localVarCall = + deleteLoadBalancerValidateBeforeCall(projectId, region, name, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Delete a given load balancer in a project. (asynchronously) DeleteLoadBalancer will delete a + * given load balancer. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call deleteLoadBalancerAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + deleteLoadBalancerValidateBeforeCall(projectId, region, name, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getCredentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getCredentialsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "credentialsRef" + "}", + localVarApiClient.escapeString(credentialsRef.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getCredentialsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + 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 getCredentials(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getCredentials(Async)"); + } + + // verify the required parameter 'credentialsRef' is set + if (credentialsRef == null) { + throw new ApiException( + "Missing the required parameter 'credentialsRef' when calling getCredentials(Async)"); + } + + return getCredentialsCall(projectId, region, credentialsRef, _callback); + } + + /** + * Get a single credential reference in a project. Get Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @return GetCredentialsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public GetCredentialsResponse getCredentials( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef) + throws ApiException { + ApiResponse localVarResp = + getCredentialsWithHttpInfo(projectId, region, credentialsRef); + return localVarResp.getData(); + } + + /** + * Get a single credential reference in a project. Get Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @return ApiResponse<GetCredentialsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse getCredentialsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef) + throws ApiException { + okhttp3.Call localVarCall = + getCredentialsValidateBeforeCall(projectId, region, credentialsRef, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a single credential reference in a project. (asynchronously) Get Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getCredentialsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getCredentialsValidateBeforeCall(projectId, region, credentialsRef, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getLoadBalancer + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 load balancer not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getLoadBalancerCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers/{name}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "name" + "}", + localVarApiClient.escapeString(name.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getLoadBalancerValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + 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 getLoadBalancer(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getLoadBalancer(Async)"); + } + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException( + "Missing the required parameter 'name' when calling getLoadBalancer(Async)"); + } + + return getLoadBalancerCall(projectId, region, name, _callback); + } + + /** + * Get a single load balancer in a project. Get Load Balancer will get a single load balancer of + * a project. This contains all the information set during creation or updates. Additionally, it + * will have information about the state of the load balancer in the form of a status field and + * error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @return LoadBalancer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 load balancer not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public LoadBalancer getLoadBalancer( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name) + throws ApiException { + ApiResponse localVarResp = + getLoadBalancerWithHttpInfo(projectId, region, name); + return localVarResp.getData(); + } + + /** + * Get a single load balancer in a project. Get Load Balancer will get a single load balancer of + * a project. This contains all the information set during creation or updates. Additionally, it + * will have information about the state of the load balancer in the form of a status field and + * error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @return ApiResponse<LoadBalancer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 load balancer not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse getLoadBalancerWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name) + throws ApiException { + okhttp3.Call localVarCall = + getLoadBalancerValidateBeforeCall(projectId, region, name, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get a single load balancer in a project. (asynchronously) Get Load Balancer will get a single + * load balancer of a project. This contains all the information set during creation or updates. + * Additionally, it will have information about the state of the load balancer in the form of a + * status field and error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 load balancer not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getLoadBalancerAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + getLoadBalancerValidateBeforeCall(projectId, region, name, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getQuota + * + * @param projectId (required) + * @param region (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getQuotaCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/quota" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getQuotaValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling getQuota(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling getQuota(Async)"); + } + + return getQuotaCall(projectId, region, _callback); + } + + /** + * Get the quota of Load Balancers in a project. Retrieves the configured Load Balancer quota + * for the project. Limit can be changed via service request. There can be 3 times as many + * observability credentials as Load Balancers. + * + * @param projectId (required) + * @param region (required) + * @return GetQuotaResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public GetQuotaResponse getQuota( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + ApiResponse localVarResp = getQuotaWithHttpInfo(projectId, region); + return localVarResp.getData(); + } + + /** + * Get the quota of Load Balancers in a project. Retrieves the configured Load Balancer quota + * for the project. Limit can be changed via service request. There can be 3 times as many + * observability credentials as Load Balancers. + * + * @param projectId (required) + * @param region (required) + * @return ApiResponse<GetQuotaResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse getQuotaWithHttpInfo( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + okhttp3.Call localVarCall = getQuotaValidateBeforeCall(projectId, region, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get the quota of Load Balancers in a project. (asynchronously) Retrieves the configured Load + * Balancer quota for the project. Limit can be changed via service request. There can be 3 + * times as many observability credentials as Load Balancers. + * + * @param projectId (required) + * @param region (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call getQuotaAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = getQuotaValidateBeforeCall(projectId, region, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listCredentials + * + * @param projectId (required) + * @param region (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listCredentialsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/credentials" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listCredentialsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'projectId' is set + if (projectId == null) { + throw new ApiException( + "Missing the required parameter 'projectId' when calling listCredentials(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listCredentials(Async)"); + } + + return listCredentialsCall(projectId, region, _callback); + } + + /** + * List all credentials in a project. List Credentials + * + * @param projectId (required) + * @param region (required) + * @return ListCredentialsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ListCredentialsResponse listCredentials( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + ApiResponse localVarResp = + listCredentialsWithHttpInfo(projectId, region); + return localVarResp.getData(); + } + + /** + * List all credentials in a project. List Credentials + * + * @param projectId (required) + * @param region (required) + * @return ApiResponse<ListCredentialsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse listCredentialsWithHttpInfo( + @javax.annotation.Nonnull String projectId, @javax.annotation.Nonnull String region) + throws ApiException { + okhttp3.Call localVarCall = listCredentialsValidateBeforeCall(projectId, region, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List all credentials in a project. (asynchronously) List Credentials + * + * @param projectId (required) + * @param region (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listCredentialsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = listCredentialsValidateBeforeCall(projectId, region, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listLoadBalancers + * + * @param projectId (required) + * @param region (required) + * @param pageSize page_size specifies how many load balancers should be returned on this page. + * Must be a positive number <= 1000 (optional) + * @param pageId page_id is a page identifier returned by the previous response and is used to + * request the next page (optional) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
410 page_id is expired -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listLoadBalancersCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable String pageSize, + @javax.annotation.Nullable String pageId, + final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (pageSize != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageSize", pageSize)); + } + + if (pageId != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("pageId", pageId)); + } + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listLoadBalancersValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable String pageSize, + @javax.annotation.Nullable String pageId, + 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 listLoadBalancers(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listLoadBalancers(Async)"); + } + + return listLoadBalancersCall(projectId, region, pageSize, pageId, _callback); + } + + /** + * List load balancers in a project. ListLoadBalancer will list load balancers of a project. + * This contains information set during creation or updates for every load balancer in the + * project. Additionally, it will have information about the state of the load balancer in the + * form of a status field and error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param pageSize page_size specifies how many load balancers should be returned on this page. + * Must be a positive number <= 1000 (optional) + * @param pageId page_id is a page identifier returned by the previous response and is used to + * request the next page (optional) + * @return ListLoadBalancersResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
410 page_id is expired -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ListLoadBalancersResponse listLoadBalancers( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable String pageSize, + @javax.annotation.Nullable String pageId) + throws ApiException { + ApiResponse localVarResp = + listLoadBalancersWithHttpInfo(projectId, region, pageSize, pageId); + return localVarResp.getData(); + } + + /** + * List load balancers in a project. ListLoadBalancer will list load balancers of a project. + * This contains information set during creation or updates for every load balancer in the + * project. Additionally, it will have information about the state of the load balancer in the + * form of a status field and error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param pageSize page_size specifies how many load balancers should be returned on this page. + * Must be a positive number <= 1000 (optional) + * @param pageId page_id is a page identifier returned by the previous response and is used to + * request the next page (optional) + * @return ApiResponse<ListLoadBalancersResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
410 page_id is expired -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse listLoadBalancersWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable String pageSize, + @javax.annotation.Nullable String pageId) + throws ApiException { + okhttp3.Call localVarCall = + listLoadBalancersValidateBeforeCall(projectId, region, pageSize, pageId, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List load balancers in a project. (asynchronously) ListLoadBalancer will list load balancers + * of a project. This contains information set during creation or updates for every load + * balancer in the project. Additionally, it will have information about the state of the load + * balancer in the form of a status field and error description feedback. + * + * @param projectId (required) + * @param region (required) + * @param pageSize page_size specifies how many load balancers should be returned on this page. + * Must be a positive number <= 1000 (optional) + * @param pageId page_id is a page identifier returned by the previous response and is used to + * request the next page (optional) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
410 page_id is expired -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listLoadBalancersAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nullable String pageSize, + @javax.annotation.Nullable String pageId, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + listLoadBalancersValidateBeforeCall(projectId, region, pageSize, pageId, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listPlans + * + * @param region (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listPlansCall( + @javax.annotation.Nonnull String region, final ApiCallback _callback) + throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] {}; + + // Determine Base Path to Use + if (localCustomBaseUrl != null) { + basePath = localCustomBaseUrl; + } else if (localBasePaths.length > 0) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/v2/regions/{region}/plans" + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = {"application/json", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listPlansValidateBeforeCall( + @javax.annotation.Nonnull String region, final ApiCallback _callback) + throws ApiException { + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling listPlans(Async)"); + } + + return listPlansCall(region, _callback); + } + + /** + * List available service plans. ListPlans returns for the configured service plans for a + * project. + * + * @param region (required) + * @return ListPlansResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ListPlansResponse listPlans(@javax.annotation.Nonnull String region) + throws ApiException { + ApiResponse localVarResp = listPlansWithHttpInfo(region); + return localVarResp.getData(); + } + + /** + * List available service plans. ListPlans returns for the configured service plans for a + * project. + * + * @param region (required) + * @return ApiResponse<ListPlansResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse listPlansWithHttpInfo( + @javax.annotation.Nonnull String region) throws ApiException { + okhttp3.Call localVarCall = listPlansValidateBeforeCall(region, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List available service plans. (asynchronously) ListPlans returns for the configured service + * plans for a project. + * + * @param region (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this projectId is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call listPlansAsync( + @javax.annotation.Nonnull String region, final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = listPlansValidateBeforeCall(region, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateCredentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param updateCredentialsPayload (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateCredentialsCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + @javax.annotation.Nonnull UpdateCredentialsPayload updateCredentialsPayload, + 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 = updateCredentialsPayload; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/credentials/{credentialsRef}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "credentialsRef" + "}", + localVarApiClient.escapeString(credentialsRef.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateCredentialsValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + @javax.annotation.Nonnull UpdateCredentialsPayload updateCredentialsPayload, + 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 updateCredentials(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateCredentials(Async)"); + } + + // verify the required parameter 'credentialsRef' is set + if (credentialsRef == null) { + throw new ApiException( + "Missing the required parameter 'credentialsRef' when calling updateCredentials(Async)"); + } + + // verify the required parameter 'updateCredentialsPayload' is set + if (updateCredentialsPayload == null) { + throw new ApiException( + "Missing the required parameter 'updateCredentialsPayload' when calling updateCredentials(Async)"); + } + + return updateCredentialsCall( + projectId, region, credentialsRef, updateCredentialsPayload, _callback); + } + + /** + * Update credentials for observability in a project. Update Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param updateCredentialsPayload (required) + * @return UpdateCredentialsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public UpdateCredentialsResponse updateCredentials( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + @javax.annotation.Nonnull UpdateCredentialsPayload updateCredentialsPayload) + throws ApiException { + ApiResponse localVarResp = + updateCredentialsWithHttpInfo( + projectId, region, credentialsRef, updateCredentialsPayload); + return localVarResp.getData(); + } + + /** + * Update credentials for observability in a project. Update Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param updateCredentialsPayload (required) + * @return ApiResponse<UpdateCredentialsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse updateCredentialsWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + @javax.annotation.Nonnull UpdateCredentialsPayload updateCredentialsPayload) + throws ApiException { + okhttp3.Call localVarCall = + updateCredentialsValidateBeforeCall( + projectId, region, credentialsRef, updateCredentialsPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update credentials for observability in a project. (asynchronously) Update Credentials + * + * @param projectId (required) + * @param region (required) + * @param credentialsRef (required) + * @param updateCredentialsPayload (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
404 credential reference not found -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateCredentialsAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String credentialsRef, + @javax.annotation.Nonnull UpdateCredentialsPayload updateCredentialsPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateCredentialsValidateBeforeCall( + projectId, region, credentialsRef, updateCredentialsPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateLoadBalancer + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param updateLoadBalancerPayload (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 Conflict with current state -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateLoadBalancerCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull UpdateLoadBalancerPayload updateLoadBalancerPayload, + 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 = updateLoadBalancerPayload; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers/{name}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "name" + "}", + localVarApiClient.escapeString(name.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateLoadBalancerValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull UpdateLoadBalancerPayload updateLoadBalancerPayload, + 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 updateLoadBalancer(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateLoadBalancer(Async)"); + } + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException( + "Missing the required parameter 'name' when calling updateLoadBalancer(Async)"); + } + + // verify the required parameter 'updateLoadBalancerPayload' is set + if (updateLoadBalancerPayload == null) { + throw new ApiException( + "Missing the required parameter 'updateLoadBalancerPayload' when calling updateLoadBalancer(Async)"); + } + + return updateLoadBalancerCall( + projectId, region, name, updateLoadBalancerPayload, _callback); + } + + /** + * Update a load balancer in a project. Update Load Balancer allows the change of listeners and + * target pools of an existing Load Balancer. The Load balancer resource version needs to be the + * current version to ensure concurrency safe updates. The default load balancing algorithm is + * round robin unless useSourceIpAddress in session persistence is enabled for a target pool + * then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param updateLoadBalancerPayload (required) + * @return LoadBalancer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 Conflict with current state -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public LoadBalancer updateLoadBalancer( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull UpdateLoadBalancerPayload updateLoadBalancerPayload) + throws ApiException { + ApiResponse localVarResp = + updateLoadBalancerWithHttpInfo(projectId, region, name, updateLoadBalancerPayload); + return localVarResp.getData(); + } + + /** + * Update a load balancer in a project. Update Load Balancer allows the change of listeners and + * target pools of an existing Load Balancer. The Load balancer resource version needs to be the + * current version to ensure concurrency safe updates. The default load balancing algorithm is + * round robin unless useSourceIpAddress in session persistence is enabled for a target pool + * then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param updateLoadBalancerPayload (required) + * @return ApiResponse<LoadBalancer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 Conflict with current state -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse updateLoadBalancerWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull UpdateLoadBalancerPayload updateLoadBalancerPayload) + throws ApiException { + okhttp3.Call localVarCall = + updateLoadBalancerValidateBeforeCall( + projectId, region, name, updateLoadBalancerPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update a load balancer in a project. (asynchronously) Update Load Balancer allows the change + * of listeners and target pools of an existing Load Balancer. The Load balancer resource + * version needs to be the current version to ensure concurrency safe updates. The default load + * balancing algorithm is round robin unless useSourceIpAddress in session persistence is + * enabled for a target pool then it is Maglev. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param updateLoadBalancerPayload (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
409 Conflict with current state -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateLoadBalancerAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull UpdateLoadBalancerPayload updateLoadBalancerPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateLoadBalancerValidateBeforeCall( + projectId, region, name, updateLoadBalancerPayload, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for updateTargetPool + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param targetPoolName (required) + * @param updateTargetPoolPayload (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateTargetPoolCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull String targetPoolName, + @javax.annotation.Nonnull UpdateTargetPoolPayload updateTargetPoolPayload, + 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 = updateTargetPoolPayload; + + // create path and map variables + String localVarPath = + "/v2/projects/{projectId}/regions/{region}/load-balancers/{name}/target-pools/{targetPoolName}" + .replace( + "{" + "projectId" + "}", + localVarApiClient.escapeString(projectId.toString())) + .replace( + "{" + "region" + "}", + localVarApiClient.escapeString(region.toString())) + .replace( + "{" + "name" + "}", localVarApiClient.escapeString(name.toString())) + .replace( + "{" + "targetPoolName" + "}", + localVarApiClient.escapeString(targetPoolName.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", "text/plain"}; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {"application/json"}; + final String localVarContentType = + localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] {}; + return localVarApiClient.buildCall( + basePath, + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateTargetPoolValidateBeforeCall( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull String targetPoolName, + @javax.annotation.Nonnull UpdateTargetPoolPayload updateTargetPoolPayload, + 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 updateTargetPool(Async)"); + } + + // verify the required parameter 'region' is set + if (region == null) { + throw new ApiException( + "Missing the required parameter 'region' when calling updateTargetPool(Async)"); + } + + // verify the required parameter 'name' is set + if (name == null) { + throw new ApiException( + "Missing the required parameter 'name' when calling updateTargetPool(Async)"); + } + + // verify the required parameter 'targetPoolName' is set + if (targetPoolName == null) { + throw new ApiException( + "Missing the required parameter 'targetPoolName' when calling updateTargetPool(Async)"); + } + + // verify the required parameter 'updateTargetPoolPayload' is set + if (updateTargetPoolPayload == null) { + throw new ApiException( + "Missing the required parameter 'updateTargetPoolPayload' when calling updateTargetPool(Async)"); + } + + return updateTargetPoolCall( + projectId, region, name, targetPoolName, updateTargetPoolPayload, _callback); + } + + /** + * Update a single target pool of a load balancer in a project. ReplaceTargetPool will replace a + * specific target pool of a load balancer with new content. Useful to add/remove target + * servers. will update a load balancer. Only replaces the mentioned target pools and leaves + * others unchanged. Cannot be used to create or rename a target pool. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param targetPoolName (required) + * @param updateTargetPoolPayload (required) + * @return TargetPool + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public TargetPool updateTargetPool( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull String targetPoolName, + @javax.annotation.Nonnull UpdateTargetPoolPayload updateTargetPoolPayload) + throws ApiException { + ApiResponse localVarResp = + updateTargetPoolWithHttpInfo( + projectId, region, name, targetPoolName, updateTargetPoolPayload); + return localVarResp.getData(); + } + + /** + * Update a single target pool of a load balancer in a project. ReplaceTargetPool will replace a + * specific target pool of a load balancer with new content. Useful to add/remove target + * servers. will update a load balancer. Only replaces the mentioned target pools and leaves + * others unchanged. Cannot be used to create or rename a target pool. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param targetPoolName (required) + * @param updateTargetPoolPayload (required) + * @return ApiResponse<TargetPool> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the + * response body + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public ApiResponse updateTargetPoolWithHttpInfo( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull String targetPoolName, + @javax.annotation.Nonnull UpdateTargetPoolPayload updateTargetPoolPayload) + throws ApiException { + okhttp3.Call localVarCall = + updateTargetPoolValidateBeforeCall( + projectId, region, name, targetPoolName, updateTargetPoolPayload, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update a single target pool of a load balancer in a project. (asynchronously) + * ReplaceTargetPool will replace a specific target pool of a load balancer with new content. + * Useful to add/remove target servers. will update a load balancer. Only replaces the mentioned + * target pools and leaves others unchanged. Cannot be used to create or rename a target pool. + * + * @param projectId (required) + * @param region (required) + * @param name (required) + * @param targetPoolName (required) + * @param updateTargetPoolPayload (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body + * object + * @http.response.details + * + * + * + * + * + * + * + * + * + *
Response Details
Status Code Description Response Headers
200 OK -
400 One or more fields are invalid. -
401 Unauthorized -
403 this project_id is not allowed to try this API -
500 internal error - please retry again later or contact support if the issue persists -
0 Default error response -
+ */ + public okhttp3.Call updateTargetPoolAsync( + @javax.annotation.Nonnull String projectId, + @javax.annotation.Nonnull String region, + @javax.annotation.Nonnull String name, + @javax.annotation.Nonnull String targetPoolName, + @javax.annotation.Nonnull UpdateTargetPoolPayload updateTargetPoolPayload, + final ApiCallback _callback) + throws ApiException { + + okhttp3.Call localVarCall = + updateTargetPoolValidateBeforeCall( + projectId, + region, + name, + targetPoolName, + updateTargetPoolPayload, + _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApi.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApi.java new file mode 100644 index 0000000..9dbe35d --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApi.java @@ -0,0 +1,64 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.api; + +import cloud.stackit.sdk.core.config.CoreConfiguration; +import java.io.IOException; +import okhttp3.OkHttpClient; + +public class LoadBalancerApi extends DefaultApi { + /** + * Basic constructor for LoadBalancerApi + * + *

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

For production use consider using the constructor with the OkHttpClient parameter. + * + * @param config your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public LoadBalancerApi(CoreConfiguration configuration) throws IOException { + super(configuration); + } + + /** + * Constructor for LoadBalancerApi + * + * @param httpClient OkHttpClient object + * @throws IOException + */ + public LoadBalancerApi(OkHttpClient httpClient) throws IOException { + super(httpClient); + } + + /** + * Constructor for LoadBalancerApi + * + * @param httpClient OkHttpClient object + * @param configuration your STACKIT SDK CoreConfiguration + * @throws IOException + */ + public LoadBalancerApi(OkHttpClient httpClient, CoreConfiguration configuration) + throws IOException { + super(httpClient, configuration); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/AbstractOpenApiSchema.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/AbstractOpenApiSchema.java new file mode 100644 index 0000000..44a0eb7 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/AbstractOpenApiSchema.java @@ -0,0 +1,145 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import java.util.Map; +import java.util.Objects; + +/** Abstract class for oneOf,anyOf schemas defined in OpenAPI spec */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public abstract class AbstractOpenApiSchema { + + // store the actual instance of the schema/object + private Object instance; + + // is nullable + private Boolean isNullable; + + // schema type (e.g. oneOf, anyOf) + private final String schemaType; + + public AbstractOpenApiSchema(String schemaType, Boolean isNullable) { + this.schemaType = schemaType; + this.isNullable = isNullable; + } + + /** + * Get the list of oneOf/anyOf composed schemas allowed to be stored in this object + * + * @return an instance of the actual schema/object + */ + public abstract Map> getSchemas(); + + /** + * Get the actual instance + * + * @return an instance of the actual schema/object + */ + // @JsonValue + public Object getActualInstance() { + return instance; + } + + /** + * Set the actual instance + * + * @param instance the actual instance of the schema/object + */ + public void setActualInstance(Object instance) { + this.instance = instance; + } + + /** + * Get the instant recursively when the schemas defined in oneOf/anyof happen to be oneOf/anyOf + * schema as well + * + * @return an instance of the actual schema/object + */ + public Object getActualInstanceRecursively() { + return getActualInstanceRecursively(this); + } + + private Object getActualInstanceRecursively(AbstractOpenApiSchema object) { + if (object.getActualInstance() == null) { + return null; + } else if (object.getActualInstance() instanceof AbstractOpenApiSchema) { + return getActualInstanceRecursively((AbstractOpenApiSchema) object.getActualInstance()); + } else { + return object.getActualInstance(); + } + } + + /** + * Get the schema type (e.g. anyOf, oneOf) + * + * @return the schema type + */ + public String getSchemaType() { + return schemaType; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ").append(getClass()).append(" {\n"); + sb.append(" instance: ").append(toIndentedString(instance)).append("\n"); + sb.append(" isNullable: ").append(toIndentedString(isNullable)).append("\n"); + sb.append(" schemaType: ").append(toIndentedString(schemaType)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AbstractOpenApiSchema a = (AbstractOpenApiSchema) o; + return Objects.equals(this.instance, a.instance) + && Objects.equals(this.isNullable, a.isNullable) + && Objects.equals(this.schemaType, a.schemaType); + } + + @Override + public int hashCode() { + return Objects.hash(instance, isNullable, schemaType); + } + + /** + * Is nullable + * + * @return true if it's nullable + */ + public Boolean isNullable() { + if (Boolean.TRUE.equals(isNullable)) { + return Boolean.TRUE; + } else { + return Boolean.FALSE; + } + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java new file mode 100644 index 0000000..5307d87 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ActiveHealthCheck.java @@ -0,0 +1,321 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ActiveHealthCheck */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ActiveHealthCheck { + public static final String SERIALIZED_NAME_HEALTHY_THRESHOLD = "healthyThreshold"; + + @SerializedName(SERIALIZED_NAME_HEALTHY_THRESHOLD) + @javax.annotation.Nullable private Integer healthyThreshold; + + public static final String SERIALIZED_NAME_INTERVAL = "interval"; + + @SerializedName(SERIALIZED_NAME_INTERVAL) + @javax.annotation.Nullable private String interval; + + public static final String SERIALIZED_NAME_INTERVAL_JITTER = "intervalJitter"; + + @SerializedName(SERIALIZED_NAME_INTERVAL_JITTER) + @javax.annotation.Nullable private String intervalJitter; + + public static final String SERIALIZED_NAME_TIMEOUT = "timeout"; + + @SerializedName(SERIALIZED_NAME_TIMEOUT) + @javax.annotation.Nullable private String timeout; + + public static final String SERIALIZED_NAME_UNHEALTHY_THRESHOLD = "unhealthyThreshold"; + + @SerializedName(SERIALIZED_NAME_UNHEALTHY_THRESHOLD) + @javax.annotation.Nullable private Integer unhealthyThreshold; + + public ActiveHealthCheck() {} + + public ActiveHealthCheck healthyThreshold(@javax.annotation.Nullable Integer healthyThreshold) { + this.healthyThreshold = healthyThreshold; + return this; + } + + /** + * Healthy threshold of the health checking minimum: 1 maximum: 1000000 + * + * @return healthyThreshold + */ + @javax.annotation.Nullable public Integer getHealthyThreshold() { + return healthyThreshold; + } + + public void setHealthyThreshold(@javax.annotation.Nullable Integer healthyThreshold) { + this.healthyThreshold = healthyThreshold; + } + + public ActiveHealthCheck interval(@javax.annotation.Nullable String interval) { + this.interval = interval; + return this; + } + + /** + * Interval duration of health checking in seconds + * + * @return interval + */ + @javax.annotation.Nullable public String getInterval() { + return interval; + } + + public void setInterval(@javax.annotation.Nullable String interval) { + this.interval = interval; + } + + public ActiveHealthCheck intervalJitter(@javax.annotation.Nullable String intervalJitter) { + this.intervalJitter = intervalJitter; + return this; + } + + /** + * Interval duration threshold of the health checking in seconds + * + * @return intervalJitter + */ + @javax.annotation.Nullable public String getIntervalJitter() { + return intervalJitter; + } + + public void setIntervalJitter(@javax.annotation.Nullable String intervalJitter) { + this.intervalJitter = intervalJitter; + } + + public ActiveHealthCheck timeout(@javax.annotation.Nullable String timeout) { + this.timeout = timeout; + return this; + } + + /** + * Active health checking timeout duration in seconds + * + * @return timeout + */ + @javax.annotation.Nullable public String getTimeout() { + return timeout; + } + + public void setTimeout(@javax.annotation.Nullable String timeout) { + this.timeout = timeout; + } + + public ActiveHealthCheck unhealthyThreshold( + @javax.annotation.Nullable Integer unhealthyThreshold) { + this.unhealthyThreshold = unhealthyThreshold; + return this; + } + + /** + * Unhealthy threshold of the health checking minimum: 1 maximum: 1000000 + * + * @return unhealthyThreshold + */ + @javax.annotation.Nullable public Integer getUnhealthyThreshold() { + return unhealthyThreshold; + } + + public void setUnhealthyThreshold(@javax.annotation.Nullable Integer unhealthyThreshold) { + this.unhealthyThreshold = unhealthyThreshold; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ActiveHealthCheck activeHealthCheck = (ActiveHealthCheck) o; + return Objects.equals(this.healthyThreshold, activeHealthCheck.healthyThreshold) + && Objects.equals(this.interval, activeHealthCheck.interval) + && Objects.equals(this.intervalJitter, activeHealthCheck.intervalJitter) + && Objects.equals(this.timeout, activeHealthCheck.timeout) + && Objects.equals(this.unhealthyThreshold, activeHealthCheck.unhealthyThreshold); + } + + @Override + public int hashCode() { + return Objects.hash( + healthyThreshold, interval, intervalJitter, timeout, unhealthyThreshold); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ActiveHealthCheck {\n"); + sb.append(" healthyThreshold: ").append(toIndentedString(healthyThreshold)).append("\n"); + sb.append(" interval: ").append(toIndentedString(interval)).append("\n"); + sb.append(" intervalJitter: ").append(toIndentedString(intervalJitter)).append("\n"); + sb.append(" timeout: ").append(toIndentedString(timeout)).append("\n"); + sb.append(" unhealthyThreshold: ") + .append(toIndentedString(unhealthyThreshold)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "healthyThreshold", + "interval", + "intervalJitter", + "timeout", + "unhealthyThreshold")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ActiveHealthCheck + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ActiveHealthCheck.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ActiveHealthCheck is not found in the empty JSON string", + ActiveHealthCheck.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ActiveHealthCheck.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ActiveHealthCheck` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("interval") != null && !jsonObj.get("interval").isJsonNull()) + && !jsonObj.get("interval").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `interval` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("interval").toString())); + } + if ((jsonObj.get("intervalJitter") != null && !jsonObj.get("intervalJitter").isJsonNull()) + && !jsonObj.get("intervalJitter").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `intervalJitter` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("intervalJitter").toString())); + } + if ((jsonObj.get("timeout") != null && !jsonObj.get("timeout").isJsonNull()) + && !jsonObj.get("timeout").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `timeout` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("timeout").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ActiveHealthCheck.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ActiveHealthCheck' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ActiveHealthCheck.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ActiveHealthCheck value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ActiveHealthCheck read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ActiveHealthCheck given an JSON string + * + * @param jsonString JSON string + * @return An instance of ActiveHealthCheck + * @throws IOException if the JSON string is invalid with respect to ActiveHealthCheck + */ + public static ActiveHealthCheck fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ActiveHealthCheck.class); + } + + /** + * Convert an instance of ActiveHealthCheck to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java new file mode 100644 index 0000000..d470e7a --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsPayload.java @@ -0,0 +1,263 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** CreateCredentialsPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateCredentialsPayload { + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nullable private String displayName; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + + @SerializedName(SERIALIZED_NAME_PASSWORD) + @javax.annotation.Nullable private String password; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + + @SerializedName(SERIALIZED_NAME_USERNAME) + @javax.annotation.Nullable private String username; + + public CreateCredentialsPayload() {} + + public CreateCredentialsPayload displayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Credential name + * + * @return displayName + */ + @javax.annotation.Nullable public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + } + + public CreateCredentialsPayload password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * A valid password used for an existing STACKIT Observability instance, which is used during + * basic auth. + * + * @return password + */ + @javax.annotation.Nullable public String getPassword() { + return password; + } + + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + public CreateCredentialsPayload username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * A valid username used for an existing STACKIT Observability instance, which is used during + * basic auth. + * + * @return username + */ + @javax.annotation.Nullable public String getUsername() { + return username; + } + + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateCredentialsPayload createCredentialsPayload = (CreateCredentialsPayload) o; + return Objects.equals(this.displayName, createCredentialsPayload.displayName) + && Objects.equals(this.password, createCredentialsPayload.password) + && Objects.equals(this.username, createCredentialsPayload.username); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, password, username); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateCredentialsPayload {\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("displayName", "password", "username")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateCredentialsPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateCredentialsPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateCredentialsPayload is not found in the empty JSON string", + CreateCredentialsPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateCredentialsPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `CreateCredentialsPayload` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) + && !jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) + && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `password` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("password").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) + && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `username` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateCredentialsPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateCredentialsPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateCredentialsPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateCredentialsPayload value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateCredentialsPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateCredentialsPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateCredentialsPayload + * @throws IOException if the JSON string is invalid with respect to CreateCredentialsPayload + */ + public static CreateCredentialsPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateCredentialsPayload.class); + } + + /** + * Convert an instance of CreateCredentialsPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java new file mode 100644 index 0000000..e8b42c1 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateCredentialsResponse.java @@ -0,0 +1,195 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** CreateCredentialsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateCredentialsResponse { + public static final String SERIALIZED_NAME_CREDENTIAL = "credential"; + + @SerializedName(SERIALIZED_NAME_CREDENTIAL) + @javax.annotation.Nullable private CredentialsResponse credential; + + public CreateCredentialsResponse() {} + + public CreateCredentialsResponse credential( + @javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + return this; + } + + /** + * Get credential + * + * @return credential + */ + @javax.annotation.Nullable public CredentialsResponse getCredential() { + return credential; + } + + public void setCredential(@javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateCredentialsResponse createCredentialsResponse = (CreateCredentialsResponse) o; + return Objects.equals(this.credential, createCredentialsResponse.credential); + } + + @Override + public int hashCode() { + return Objects.hash(credential); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateCredentialsResponse {\n"); + sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credential")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateCredentialsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateCredentialsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateCredentialsResponse is not found in the empty JSON string", + CreateCredentialsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateCredentialsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `CreateCredentialsResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `credential` + if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { + CredentialsResponse.validateJsonElement(jsonObj.get("credential")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateCredentialsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateCredentialsResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateCredentialsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateCredentialsResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateCredentialsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateCredentialsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateCredentialsResponse + * @throws IOException if the JSON string is invalid with respect to CreateCredentialsResponse + */ + public static CreateCredentialsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateCredentialsResponse.class); + } + + /** + * Convert an instance of CreateCredentialsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java new file mode 100644 index 0000000..df8c49b --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CreateLoadBalancerPayload.java @@ -0,0 +1,848 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** CreateLoadBalancerPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CreateLoadBalancerPayload { + public static final String SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT = + "disableTargetSecurityGroupAssignment"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT) + @javax.annotation.Nullable private Boolean disableTargetSecurityGroupAssignment; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_EXTERNAL_ADDRESS = "externalAddress"; + + @SerializedName(SERIALIZED_NAME_EXTERNAL_ADDRESS) + @javax.annotation.Nullable private String externalAddress; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + + @SerializedName(SERIALIZED_NAME_LISTENERS) + @javax.annotation.Nullable private List listeners = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP = + "loadBalancerSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup loadBalancerSecurityGroup; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_NETWORKS = "networks"; + + @SerializedName(SERIALIZED_NAME_NETWORKS) + @javax.annotation.Nullable private List networks = new ArrayList<>(); + + public static final String SERIALIZED_NAME_OPTIONS = "options"; + + @SerializedName(SERIALIZED_NAME_OPTIONS) + @javax.annotation.Nullable private LoadBalancerOptions options; + + public static final String SERIALIZED_NAME_PLAN_ID = "planId"; + + @SerializedName(SERIALIZED_NAME_PLAN_ID) + @javax.annotation.Nullable private String planId; + + public static final String SERIALIZED_NAME_PRIVATE_ADDRESS = "privateAddress"; + + @SerializedName(SERIALIZED_NAME_PRIVATE_ADDRESS) + @javax.annotation.Nullable private String privateAddress; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + /** Gets or Sets status */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"), + + STATUS_PENDING("STATUS_PENDING"), + + STATUS_READY("STATUS_READY"), + + STATUS_ERROR("STATUS_ERROR"), + + STATUS_TERMINATING("STATUS_TERMINATING"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable private StatusEnum status; + + public static final String SERIALIZED_NAME_TARGET_POOLS = "targetPools"; + + @SerializedName(SERIALIZED_NAME_TARGET_POOLS) + @javax.annotation.Nullable private List targetPools = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TARGET_SECURITY_GROUP = "targetSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_TARGET_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup targetSecurityGroup; + + public static final String SERIALIZED_NAME_VERSION = "version"; + + @SerializedName(SERIALIZED_NAME_VERSION) + @javax.annotation.Nullable private String version; + + public CreateLoadBalancerPayload() {} + + public CreateLoadBalancerPayload( + List errors, + SecurityGroup loadBalancerSecurityGroup, + String privateAddress, + String region, + StatusEnum status, + SecurityGroup targetSecurityGroup) { + this(); + this.errors = errors; + this.loadBalancerSecurityGroup = loadBalancerSecurityGroup; + this.privateAddress = privateAddress; + this.region = region; + this.status = status; + this.targetSecurityGroup = targetSecurityGroup; + } + + public CreateLoadBalancerPayload disableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + return this; + } + + /** + * Disable target security group assignemt to allow targets outside of the given network. + * Connectivity to targets need to be ensured by the customer, including routing and Security + * Groups (targetSecurityGroup can be assigned). Not changeable after creation. + * + * @return disableTargetSecurityGroupAssignment + */ + @javax.annotation.Nullable public Boolean getDisableTargetSecurityGroupAssignment() { + return disableTargetSecurityGroupAssignment; + } + + public void setDisableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + } + + /** + * Reports all errors a load balancer has. + * + * @return errors + */ + @javax.annotation.Nullable public List getErrors() { + return errors; + } + + public CreateLoadBalancerPayload externalAddress( + @javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + return this; + } + + /** + * External load balancer IP address where this load balancer is exposed. Not changeable after + * creation. + * + * @return externalAddress + */ + @javax.annotation.Nullable public String getExternalAddress() { + return externalAddress; + } + + public void setExternalAddress(@javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + } + + public CreateLoadBalancerPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public CreateLoadBalancerPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 + * per LB. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end + * with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in + * between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage + * them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). + * Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes + * (-), underscores (_), dots (.), and alphanumerics in between. + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public CreateLoadBalancerPayload listeners( + @javax.annotation.Nullable List listeners) { + this.listeners = listeners; + return this; + } + + public CreateLoadBalancerPayload addListenersItem(Listener listenersItem) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listenersItem); + return this; + } + + /** + * There is a maximum listener count of 20. Port and protocol limitations: - UDP listeners + * cannot have the same port. - TCP-derived listeners cannot have the same port. A TCP-derived + * listener is any listener that listens on a TCP port. As of now those are: TCP, TCP_PROXY, and + * PROTOCOL_TLS_PASSTHROUGH. The only exception is, if all listeners for the same port are + * PROTOCOL_TLS_PASSTHROUGH. - PROTOCOL_TLS_PASSTHROUGH listeners cannot have the same port and + * at least one common domain name. - PROTOCOL_TLS_PASSTHROUGH listeners can have the same + * domain name and different ports though (e.g. ports 443 and 8443 for domain example.com). - + * PROTOCOL_TLS_PASSTHROUGH listeners without a domain name serve as a default listener and you + * can have only one default listener. + * + * @return listeners + */ + @javax.annotation.Nullable public List getListeners() { + return listeners; + } + + public void setListeners(@javax.annotation.Nullable List listeners) { + this.listeners = listeners; + } + + /** + * Security Group permitting network traffic from the LoadBalancer to the targets. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return loadBalancerSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getLoadBalancerSecurityGroup() { + return loadBalancerSecurityGroup; + } + + public CreateLoadBalancerPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Load balancer name. Not changeable after creation. + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public CreateLoadBalancerPayload networks(@javax.annotation.Nullable List networks) { + this.networks = networks; + return this; + } + + public CreateLoadBalancerPayload addNetworksItem(Network networksItem) { + if (this.networks == null) { + this.networks = new ArrayList<>(); + } + this.networks.add(networksItem); + return this; + } + + /** + * List of networks that listeners and targets reside in. Currently limited to one. Not + * changeable after creation. + * + * @return networks + */ + @javax.annotation.Nullable public List getNetworks() { + return networks; + } + + public void setNetworks(@javax.annotation.Nullable List networks) { + this.networks = networks; + } + + public CreateLoadBalancerPayload options( + @javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + return this; + } + + /** + * Get options + * + * @return options + */ + @javax.annotation.Nullable public LoadBalancerOptions getOptions() { + return options; + } + + public void setOptions(@javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + } + + public CreateLoadBalancerPayload planId(@javax.annotation.Nullable String planId) { + this.planId = planId; + return this; + } + + /** + * Service Plan configures the size of the Load Balancer. Currently supported plans are p10, + * p50, p250 and p750. This list can change in the future where plan ids will be removed and new + * plans by added. That is the reason this is not an enum. + * + * @return planId + */ + @javax.annotation.Nullable public String getPlanId() { + return planId; + } + + public void setPlanId(@javax.annotation.Nullable String planId) { + this.planId = planId; + } + + /** + * Transient private load balancer IP address that can change any time. + * + * @return privateAddress + */ + @javax.annotation.Nullable public String getPrivateAddress() { + return privateAddress; + } + + /** + * Region of the LoadBalancer + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nullable public StatusEnum getStatus() { + return status; + } + + public CreateLoadBalancerPayload targetPools( + @javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + return this; + } + + public CreateLoadBalancerPayload addTargetPoolsItem(TargetPool targetPoolsItem) { + if (this.targetPools == null) { + this.targetPools = new ArrayList<>(); + } + this.targetPools.add(targetPoolsItem); + return this; + } + + /** + * List of all target pools which will be used in the load balancer. Limited to 20. + * + * @return targetPools + */ + @javax.annotation.Nullable public List getTargetPools() { + return targetPools; + } + + public void setTargetPools(@javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + } + + /** + * Security Group that allows the targets to receive traffic from the LoadBalancer. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return targetSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getTargetSecurityGroup() { + return targetSecurityGroup; + } + + public CreateLoadBalancerPayload version(@javax.annotation.Nullable String version) { + this.version = version; + return this; + } + + /** + * Load balancer resource version. Must be empty or unset for creating load balancers, non-empty + * for updating load balancers. Semantics: While retrieving load balancers, this is the current + * version of this load balancer resource that changes during updates of the load balancers. On + * updates this field specified the load balancer version you calculated your update for instead + * of the future version to enable concurrency safe updates. Update calls will then report the + * new version in their result as you would see with a load balancer retrieval call later. There + * exist no total order of the version, so you can only compare it for equality, but not for + * less/greater than another version. Since the creation of load balancer is always intended to + * create the first version of it, there should be no existing version. That's why this + * field must by empty of not present in that case. + * + * @return version + */ + @javax.annotation.Nullable public String getVersion() { + return version; + } + + public void setVersion(@javax.annotation.Nullable String version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateLoadBalancerPayload createLoadBalancerPayload = (CreateLoadBalancerPayload) o; + return Objects.equals( + this.disableTargetSecurityGroupAssignment, + createLoadBalancerPayload.disableTargetSecurityGroupAssignment) + && Objects.equals(this.errors, createLoadBalancerPayload.errors) + && Objects.equals(this.externalAddress, createLoadBalancerPayload.externalAddress) + && Objects.equals(this.labels, createLoadBalancerPayload.labels) + && Objects.equals(this.listeners, createLoadBalancerPayload.listeners) + && Objects.equals( + this.loadBalancerSecurityGroup, + createLoadBalancerPayload.loadBalancerSecurityGroup) + && Objects.equals(this.name, createLoadBalancerPayload.name) + && Objects.equals(this.networks, createLoadBalancerPayload.networks) + && Objects.equals(this.options, createLoadBalancerPayload.options) + && Objects.equals(this.planId, createLoadBalancerPayload.planId) + && Objects.equals(this.privateAddress, createLoadBalancerPayload.privateAddress) + && Objects.equals(this.region, createLoadBalancerPayload.region) + && Objects.equals(this.status, createLoadBalancerPayload.status) + && Objects.equals(this.targetPools, createLoadBalancerPayload.targetPools) + && Objects.equals( + this.targetSecurityGroup, createLoadBalancerPayload.targetSecurityGroup) + && Objects.equals(this.version, createLoadBalancerPayload.version); + } + + @Override + public int hashCode() { + return Objects.hash( + disableTargetSecurityGroupAssignment, + errors, + externalAddress, + labels, + listeners, + loadBalancerSecurityGroup, + name, + networks, + options, + planId, + privateAddress, + region, + status, + targetPools, + targetSecurityGroup, + version); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateLoadBalancerPayload {\n"); + sb.append(" disableTargetSecurityGroupAssignment: ") + .append(toIndentedString(disableTargetSecurityGroupAssignment)) + .append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" externalAddress: ").append(toIndentedString(externalAddress)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); + sb.append(" loadBalancerSecurityGroup: ") + .append(toIndentedString(loadBalancerSecurityGroup)) + .append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" networks: ").append(toIndentedString(networks)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append(" planId: ").append(toIndentedString(planId)).append("\n"); + sb.append(" privateAddress: ").append(toIndentedString(privateAddress)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" targetPools: ").append(toIndentedString(targetPools)).append("\n"); + sb.append(" targetSecurityGroup: ") + .append(toIndentedString(targetSecurityGroup)) + .append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "disableTargetSecurityGroupAssignment", + "errors", + "externalAddress", + "labels", + "listeners", + "loadBalancerSecurityGroup", + "name", + "networks", + "options", + "planId", + "privateAddress", + "region", + "status", + "targetPools", + "targetSecurityGroup", + "version")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateLoadBalancerPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateLoadBalancerPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CreateLoadBalancerPayload is not found in the empty JSON string", + CreateLoadBalancerPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CreateLoadBalancerPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `CreateLoadBalancerPayload` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `errors` to be an array in the JSON string but got `%s`", + jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + LoadBalancerError.validateJsonElement(jsonArrayerrors.get(i)); + } + ; + } + } + if ((jsonObj.get("externalAddress") != null && !jsonObj.get("externalAddress").isJsonNull()) + && !jsonObj.get("externalAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `externalAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("externalAddress").toString())); + } + if (jsonObj.get("listeners") != null && !jsonObj.get("listeners").isJsonNull()) { + JsonArray jsonArraylisteners = jsonObj.getAsJsonArray("listeners"); + if (jsonArraylisteners != null) { + // ensure the json data is an array + if (!jsonObj.get("listeners").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `listeners` to be an array in the JSON string but got `%s`", + jsonObj.get("listeners").toString())); + } + + // validate the optional field `listeners` (array) + for (int i = 0; i < jsonArraylisteners.size(); i++) { + Listener.validateJsonElement(jsonArraylisteners.get(i)); + } + ; + } + } + // validate the optional field `loadBalancerSecurityGroup` + if (jsonObj.get("loadBalancerSecurityGroup") != null + && !jsonObj.get("loadBalancerSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("loadBalancerSecurityGroup")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (jsonObj.get("networks") != null && !jsonObj.get("networks").isJsonNull()) { + JsonArray jsonArraynetworks = jsonObj.getAsJsonArray("networks"); + if (jsonArraynetworks != null) { + // ensure the json data is an array + if (!jsonObj.get("networks").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `networks` to be an array in the JSON string but got `%s`", + jsonObj.get("networks").toString())); + } + + // validate the optional field `networks` (array) + for (int i = 0; i < jsonArraynetworks.size(); i++) { + Network.validateJsonElement(jsonArraynetworks.get(i)); + } + ; + } + } + // validate the optional field `options` + if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { + LoadBalancerOptions.validateJsonElement(jsonObj.get("options")); + } + if ((jsonObj.get("planId") != null && !jsonObj.get("planId").isJsonNull()) + && !jsonObj.get("planId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `planId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("planId").toString())); + } + if ((jsonObj.get("privateAddress") != null && !jsonObj.get("privateAddress").isJsonNull()) + && !jsonObj.get("privateAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `privateAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("privateAddress").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) + && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `status` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("status").toString())); + } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + if (jsonObj.get("targetPools") != null && !jsonObj.get("targetPools").isJsonNull()) { + JsonArray jsonArraytargetPools = jsonObj.getAsJsonArray("targetPools"); + if (jsonArraytargetPools != null) { + // ensure the json data is an array + if (!jsonObj.get("targetPools").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targetPools` to be an array in the JSON string but got `%s`", + jsonObj.get("targetPools").toString())); + } + + // validate the optional field `targetPools` (array) + for (int i = 0; i < jsonArraytargetPools.size(); i++) { + TargetPool.validateJsonElement(jsonArraytargetPools.get(i)); + } + ; + } + } + // validate the optional field `targetSecurityGroup` + if (jsonObj.get("targetSecurityGroup") != null + && !jsonObj.get("targetSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("targetSecurityGroup")); + } + if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) + && !jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `version` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("version").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateLoadBalancerPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateLoadBalancerPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CreateLoadBalancerPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateLoadBalancerPayload value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CreateLoadBalancerPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CreateLoadBalancerPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateLoadBalancerPayload + * @throws IOException if the JSON string is invalid with respect to CreateLoadBalancerPayload + */ + public static CreateLoadBalancerPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateLoadBalancerPayload.class); + } + + /** + * Convert an instance of CreateLoadBalancerPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java new file mode 100644 index 0000000..2ef19e6 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/CredentialsResponse.java @@ -0,0 +1,294 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** CredentialsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class CredentialsResponse { + public static final String SERIALIZED_NAME_CREDENTIALS_REF = "credentialsRef"; + + @SerializedName(SERIALIZED_NAME_CREDENTIALS_REF) + @javax.annotation.Nullable private String credentialsRef; + + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nullable private String displayName; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + + @SerializedName(SERIALIZED_NAME_USERNAME) + @javax.annotation.Nullable private String username; + + public CredentialsResponse() {} + + public CredentialsResponse credentialsRef(@javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + return this; + } + + /** + * The credentials reference can be used for observability of the Load Balancer. + * + * @return credentialsRef + */ + @javax.annotation.Nullable public String getCredentialsRef() { + return credentialsRef; + } + + public void setCredentialsRef(@javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + } + + public CredentialsResponse displayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Credential name + * + * @return displayName + */ + @javax.annotation.Nullable public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + } + + public CredentialsResponse region(@javax.annotation.Nullable String region) { + this.region = region; + return this; + } + + /** + * Region of the Credential + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + public void setRegion(@javax.annotation.Nullable String region) { + this.region = region; + } + + public CredentialsResponse username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * The username used for the STACKIT Observability instance + * + * @return username + */ + @javax.annotation.Nullable public String getUsername() { + return username; + } + + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CredentialsResponse credentialsResponse = (CredentialsResponse) o; + return Objects.equals(this.credentialsRef, credentialsResponse.credentialsRef) + && Objects.equals(this.displayName, credentialsResponse.displayName) + && Objects.equals(this.region, credentialsResponse.region) + && Objects.equals(this.username, credentialsResponse.username); + } + + @Override + public int hashCode() { + return Objects.hash(credentialsRef, displayName, region, username); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CredentialsResponse {\n"); + sb.append(" credentialsRef: ").append(toIndentedString(credentialsRef)).append("\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList("credentialsRef", "displayName", "region", "username")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CredentialsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CredentialsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in CredentialsResponse is not found in the empty JSON string", + CredentialsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!CredentialsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `CredentialsResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) + && !jsonObj.get("credentialsRef").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `credentialsRef` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("credentialsRef").toString())); + } + if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) + && !jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) + && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `username` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CredentialsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CredentialsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(CredentialsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, CredentialsResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public CredentialsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of CredentialsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CredentialsResponse + * @throws IOException if the JSON string is invalid with respect to CredentialsResponse + */ + public static CredentialsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CredentialsResponse.class); + } + + /** + * Convert an instance of CredentialsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java new file mode 100644 index 0000000..8166335 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetCredentialsResponse.java @@ -0,0 +1,194 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** GetCredentialsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetCredentialsResponse { + public static final String SERIALIZED_NAME_CREDENTIAL = "credential"; + + @SerializedName(SERIALIZED_NAME_CREDENTIAL) + @javax.annotation.Nullable private CredentialsResponse credential; + + public GetCredentialsResponse() {} + + public GetCredentialsResponse credential( + @javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + return this; + } + + /** + * Get credential + * + * @return credential + */ + @javax.annotation.Nullable public CredentialsResponse getCredential() { + return credential; + } + + public void setCredential(@javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetCredentialsResponse getCredentialsResponse = (GetCredentialsResponse) o; + return Objects.equals(this.credential, getCredentialsResponse.credential); + } + + @Override + public int hashCode() { + return Objects.hash(credential); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetCredentialsResponse {\n"); + sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credential")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetCredentialsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetCredentialsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetCredentialsResponse is not found in the empty JSON string", + GetCredentialsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetCredentialsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `GetCredentialsResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `credential` + if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { + CredentialsResponse.validateJsonElement(jsonObj.get("credential")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetCredentialsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetCredentialsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetCredentialsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetCredentialsResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetCredentialsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetCredentialsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetCredentialsResponse + * @throws IOException if the JSON string is invalid with respect to GetCredentialsResponse + */ + public static GetCredentialsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetCredentialsResponse.class); + } + + /** + * Convert an instance of GetCredentialsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java new file mode 100644 index 0000000..9fb9b7a --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GetQuotaResponse.java @@ -0,0 +1,244 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; + +/** GetQuotaResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GetQuotaResponse { + public static final String SERIALIZED_NAME_MAX_LOAD_BALANCERS = "maxLoadBalancers"; + + @SerializedName(SERIALIZED_NAME_MAX_LOAD_BALANCERS) + @javax.annotation.Nullable private Integer maxLoadBalancers; + + public static final String SERIALIZED_NAME_PROJECT_ID = "projectId"; + + @SerializedName(SERIALIZED_NAME_PROJECT_ID) + @javax.annotation.Nullable private UUID projectId; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + public GetQuotaResponse() {} + + public GetQuotaResponse(UUID projectId, String region) { + this(); + this.projectId = projectId; + this.region = region; + } + + public GetQuotaResponse maxLoadBalancers(@javax.annotation.Nullable Integer maxLoadBalancers) { + this.maxLoadBalancers = maxLoadBalancers; + return this; + } + + /** + * The maximum number of load balancing servers in this project. Unlimited if set to -1. + * minimum: -1 maximum: 1000000 + * + * @return maxLoadBalancers + */ + @javax.annotation.Nullable public Integer getMaxLoadBalancers() { + return maxLoadBalancers; + } + + public void setMaxLoadBalancers(@javax.annotation.Nullable Integer maxLoadBalancers) { + this.maxLoadBalancers = maxLoadBalancers; + } + + /** + * Project identifier + * + * @return projectId + */ + @javax.annotation.Nullable public UUID getProjectId() { + return projectId; + } + + /** + * Region + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GetQuotaResponse getQuotaResponse = (GetQuotaResponse) o; + return Objects.equals(this.maxLoadBalancers, getQuotaResponse.maxLoadBalancers) + && Objects.equals(this.projectId, getQuotaResponse.projectId) + && Objects.equals(this.region, getQuotaResponse.region); + } + + @Override + public int hashCode() { + return Objects.hash(maxLoadBalancers, projectId, region); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GetQuotaResponse {\n"); + sb.append(" maxLoadBalancers: ").append(toIndentedString(maxLoadBalancers)).append("\n"); + sb.append(" projectId: ").append(toIndentedString(projectId)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet(Arrays.asList("maxLoadBalancers", "projectId", "region")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GetQuotaResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GetQuotaResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GetQuotaResponse is not found in the empty JSON string", + GetQuotaResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!GetQuotaResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `GetQuotaResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("projectId") != null && !jsonObj.get("projectId").isJsonNull()) + && !jsonObj.get("projectId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `projectId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("projectId").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GetQuotaResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GetQuotaResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GetQuotaResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GetQuotaResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public GetQuotaResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of GetQuotaResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of GetQuotaResponse + * @throws IOException if the JSON string is invalid with respect to GetQuotaResponse + */ + public static GetQuotaResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GetQuotaResponse.class); + } + + /** + * Convert an instance of GetQuotaResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GoogleProtobufAny.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GoogleProtobufAny.java new file mode 100644 index 0000000..71d3029 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/GoogleProtobufAny.java @@ -0,0 +1,295 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** + * Contains an arbitrary serialized message along with a @type that describes the type of the + * serialized message. + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class GoogleProtobufAny { + public static final String SERIALIZED_NAME_AT_TYPE = "@type"; + + @SerializedName(SERIALIZED_NAME_AT_TYPE) + @javax.annotation.Nullable private String atType; + + public GoogleProtobufAny() {} + + public GoogleProtobufAny atType(@javax.annotation.Nullable String atType) { + this.atType = atType; + return this; + } + + /** + * The type of the serialized message. + * + * @return atType + */ + @javax.annotation.Nullable public String getAtType() { + return atType; + } + + public void setAtType(@javax.annotation.Nullable String atType) { + this.atType = atType; + } + + /** + * A container for additional, undeclared properties. This is a holder for any undeclared + * properties as specified with the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. If the property + * does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the GoogleProtobufAny instance itself + */ + public GoogleProtobufAny putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + GoogleProtobufAny googleProtobufAny = (GoogleProtobufAny) o; + return Objects.equals(this.atType, googleProtobufAny.atType) + && Objects.equals( + this.additionalProperties, googleProtobufAny.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(atType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class GoogleProtobufAny {\n"); + sb.append(" atType: ").append(toIndentedString(atType)).append("\n"); + sb.append(" additionalProperties: ") + .append(toIndentedString(additionalProperties)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("@type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to GoogleProtobufAny + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!GoogleProtobufAny.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in GoogleProtobufAny is not found in the empty JSON string", + GoogleProtobufAny.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("@type") != null && !jsonObj.get("@type").isJsonNull()) + && !jsonObj.get("@type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `@type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("@type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!GoogleProtobufAny.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'GoogleProtobufAny' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(GoogleProtobufAny.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, GoogleProtobufAny value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : + value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty( + entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public GoogleProtobufAny read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + GoogleProtobufAny instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty( + entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty( + entry.getKey(), + entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException( + String.format( + "The field `%s` has unknown primitive type. Value: %s", + entry.getKey(), + entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty( + entry.getKey(), + gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + }.nullSafe(); + } + } + + /** + * Create an instance of GoogleProtobufAny given an JSON string + * + * @param jsonString JSON string + * @return An instance of GoogleProtobufAny + * @throws IOException if the JSON string is invalid with respect to GoogleProtobufAny + */ + public static GoogleProtobufAny fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, GoogleProtobufAny.class); + } + + /** + * Convert an instance of GoogleProtobufAny to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java new file mode 100644 index 0000000..3d8062f --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListCredentialsResponse.java @@ -0,0 +1,220 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ListCredentialsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListCredentialsResponse { + public static final String SERIALIZED_NAME_CREDENTIALS = "credentials"; + + @SerializedName(SERIALIZED_NAME_CREDENTIALS) + @javax.annotation.Nullable private List credentials = new ArrayList<>(); + + public ListCredentialsResponse() {} + + public ListCredentialsResponse credentials( + @javax.annotation.Nullable List credentials) { + this.credentials = credentials; + return this; + } + + public ListCredentialsResponse addCredentialsItem(CredentialsResponse credentialsItem) { + if (this.credentials == null) { + this.credentials = new ArrayList<>(); + } + this.credentials.add(credentialsItem); + return this; + } + + /** + * Get credentials + * + * @return credentials + */ + @javax.annotation.Nullable public List getCredentials() { + return credentials; + } + + public void setCredentials(@javax.annotation.Nullable List credentials) { + this.credentials = credentials; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListCredentialsResponse listCredentialsResponse = (ListCredentialsResponse) o; + return Objects.equals(this.credentials, listCredentialsResponse.credentials); + } + + @Override + public int hashCode() { + return Objects.hash(credentials); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListCredentialsResponse {\n"); + sb.append(" credentials: ").append(toIndentedString(credentials)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credentials")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListCredentialsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListCredentialsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListCredentialsResponse is not found in the empty JSON string", + ListCredentialsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListCredentialsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ListCredentialsResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("credentials") != null && !jsonObj.get("credentials").isJsonNull()) { + JsonArray jsonArraycredentials = jsonObj.getAsJsonArray("credentials"); + if (jsonArraycredentials != null) { + // ensure the json data is an array + if (!jsonObj.get("credentials").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `credentials` to be an array in the JSON string but got `%s`", + jsonObj.get("credentials").toString())); + } + + // validate the optional field `credentials` (array) + for (int i = 0; i < jsonArraycredentials.size(); i++) { + CredentialsResponse.validateJsonElement(jsonArraycredentials.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListCredentialsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListCredentialsResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListCredentialsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListCredentialsResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListCredentialsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListCredentialsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListCredentialsResponse + * @throws IOException if the JSON string is invalid with respect to ListCredentialsResponse + */ + public static ListCredentialsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListCredentialsResponse.class); + } + + /** + * Convert an instance of ListCredentialsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java new file mode 100644 index 0000000..5cea062 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListLoadBalancersResponse.java @@ -0,0 +1,252 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ListLoadBalancersResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListLoadBalancersResponse { + public static final String SERIALIZED_NAME_LOAD_BALANCERS = "loadBalancers"; + + @SerializedName(SERIALIZED_NAME_LOAD_BALANCERS) + @javax.annotation.Nullable private List loadBalancers = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NEXT_PAGE_ID = "nextPageId"; + + @SerializedName(SERIALIZED_NAME_NEXT_PAGE_ID) + @javax.annotation.Nullable private String nextPageId; + + public ListLoadBalancersResponse() {} + + public ListLoadBalancersResponse loadBalancers( + @javax.annotation.Nullable List loadBalancers) { + this.loadBalancers = loadBalancers; + return this; + } + + public ListLoadBalancersResponse addLoadBalancersItem(LoadBalancer loadBalancersItem) { + if (this.loadBalancers == null) { + this.loadBalancers = new ArrayList<>(); + } + this.loadBalancers.add(loadBalancersItem); + return this; + } + + /** + * Get loadBalancers + * + * @return loadBalancers + */ + @javax.annotation.Nullable public List getLoadBalancers() { + return loadBalancers; + } + + public void setLoadBalancers(@javax.annotation.Nullable List loadBalancers) { + this.loadBalancers = loadBalancers; + } + + public ListLoadBalancersResponse nextPageId(@javax.annotation.Nullable String nextPageId) { + this.nextPageId = nextPageId; + return this; + } + + /** + * Continue token from the ListLoadBalancerResponse with Limit option + * + * @return nextPageId + */ + @javax.annotation.Nullable public String getNextPageId() { + return nextPageId; + } + + public void setNextPageId(@javax.annotation.Nullable String nextPageId) { + this.nextPageId = nextPageId; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListLoadBalancersResponse listLoadBalancersResponse = (ListLoadBalancersResponse) o; + return Objects.equals(this.loadBalancers, listLoadBalancersResponse.loadBalancers) + && Objects.equals(this.nextPageId, listLoadBalancersResponse.nextPageId); + } + + @Override + public int hashCode() { + return Objects.hash(loadBalancers, nextPageId); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListLoadBalancersResponse {\n"); + sb.append(" loadBalancers: ").append(toIndentedString(loadBalancers)).append("\n"); + sb.append(" nextPageId: ").append(toIndentedString(nextPageId)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("loadBalancers", "nextPageId")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListLoadBalancersResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListLoadBalancersResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListLoadBalancersResponse is not found in the empty JSON string", + ListLoadBalancersResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListLoadBalancersResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ListLoadBalancersResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("loadBalancers") != null && !jsonObj.get("loadBalancers").isJsonNull()) { + JsonArray jsonArrayloadBalancers = jsonObj.getAsJsonArray("loadBalancers"); + if (jsonArrayloadBalancers != null) { + // ensure the json data is an array + if (!jsonObj.get("loadBalancers").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `loadBalancers` to be an array in the JSON string but got `%s`", + jsonObj.get("loadBalancers").toString())); + } + + // validate the optional field `loadBalancers` (array) + for (int i = 0; i < jsonArrayloadBalancers.size(); i++) { + LoadBalancer.validateJsonElement(jsonArrayloadBalancers.get(i)); + } + ; + } + } + if ((jsonObj.get("nextPageId") != null && !jsonObj.get("nextPageId").isJsonNull()) + && !jsonObj.get("nextPageId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `nextPageId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("nextPageId").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListLoadBalancersResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListLoadBalancersResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListLoadBalancersResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListLoadBalancersResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListLoadBalancersResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListLoadBalancersResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListLoadBalancersResponse + * @throws IOException if the JSON string is invalid with respect to ListLoadBalancersResponse + */ + public static ListLoadBalancersResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListLoadBalancersResponse.class); + } + + /** + * Convert an instance of ListLoadBalancersResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java new file mode 100644 index 0000000..2d148df --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ListPlansResponse.java @@ -0,0 +1,218 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ListPlansResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ListPlansResponse { + public static final String SERIALIZED_NAME_VALID_PLANS = "validPlans"; + + @SerializedName(SERIALIZED_NAME_VALID_PLANS) + @javax.annotation.Nullable private List validPlans = new ArrayList<>(); + + public ListPlansResponse() {} + + public ListPlansResponse validPlans(@javax.annotation.Nullable List validPlans) { + this.validPlans = validPlans; + return this; + } + + public ListPlansResponse addValidPlansItem(PlanDetails validPlansItem) { + if (this.validPlans == null) { + this.validPlans = new ArrayList<>(); + } + this.validPlans.add(validPlansItem); + return this; + } + + /** + * Get validPlans + * + * @return validPlans + */ + @javax.annotation.Nullable public List getValidPlans() { + return validPlans; + } + + public void setValidPlans(@javax.annotation.Nullable List validPlans) { + this.validPlans = validPlans; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListPlansResponse listPlansResponse = (ListPlansResponse) o; + return Objects.equals(this.validPlans, listPlansResponse.validPlans); + } + + @Override + public int hashCode() { + return Objects.hash(validPlans); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListPlansResponse {\n"); + sb.append(" validPlans: ").append(toIndentedString(validPlans)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("validPlans")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListPlansResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListPlansResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ListPlansResponse is not found in the empty JSON string", + ListPlansResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ListPlansResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ListPlansResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("validPlans") != null && !jsonObj.get("validPlans").isJsonNull()) { + JsonArray jsonArrayvalidPlans = jsonObj.getAsJsonArray("validPlans"); + if (jsonArrayvalidPlans != null) { + // ensure the json data is an array + if (!jsonObj.get("validPlans").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `validPlans` to be an array in the JSON string but got `%s`", + jsonObj.get("validPlans").toString())); + } + + // validate the optional field `validPlans` (array) + for (int i = 0; i < jsonArrayvalidPlans.size(); i++) { + PlanDetails.validateJsonElement(jsonArrayvalidPlans.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListPlansResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListPlansResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ListPlansResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ListPlansResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ListPlansResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ListPlansResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListPlansResponse + * @throws IOException if the JSON string is invalid with respect to ListPlansResponse + */ + public static ListPlansResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListPlansResponse.class); + } + + /** + * Convert an instance of ListPlansResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java new file mode 100644 index 0000000..61723e9 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Listener.java @@ -0,0 +1,511 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Listener */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Listener { + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nullable private String displayName; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PORT = "port"; + + @SerializedName(SERIALIZED_NAME_PORT) + @javax.annotation.Nullable private Integer port; + + /** + * Protocol is the highest network protocol we understand to load balance. Currently only + * PROTOCOL_TCP, PROTOCOL_TCP_PROXY and PROTOCOL_TLS_PASSTHROUGH are supported. + */ + @JsonAdapter(ProtocolEnum.Adapter.class) + public enum ProtocolEnum { + PROTOCOL_UNSPECIFIED("PROTOCOL_UNSPECIFIED"), + + PROTOCOL_TCP("PROTOCOL_TCP"), + + PROTOCOL_UDP("PROTOCOL_UDP"), + + PROTOCOL_TCP_PROXY("PROTOCOL_TCP_PROXY"), + + PROTOCOL_TLS_PASSTHROUGH("PROTOCOL_TLS_PASSTHROUGH"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + ProtocolEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ProtocolEnum fromValue(String value) { + for (ProtocolEnum b : ProtocolEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final ProtocolEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ProtocolEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ProtocolEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + ProtocolEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_PROTOCOL = "protocol"; + + @SerializedName(SERIALIZED_NAME_PROTOCOL) + @javax.annotation.Nullable private ProtocolEnum protocol; + + public static final String SERIALIZED_NAME_SERVER_NAME_INDICATORS = "serverNameIndicators"; + + @SerializedName(SERIALIZED_NAME_SERVER_NAME_INDICATORS) + @javax.annotation.Nullable private List serverNameIndicators = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TARGET_POOL = "targetPool"; + + @SerializedName(SERIALIZED_NAME_TARGET_POOL) + @javax.annotation.Nullable private String targetPool; + + public static final String SERIALIZED_NAME_TCP = "tcp"; + + @SerializedName(SERIALIZED_NAME_TCP) + @javax.annotation.Nullable private OptionsTCP tcp; + + public static final String SERIALIZED_NAME_UDP = "udp"; + + @SerializedName(SERIALIZED_NAME_UDP) + @javax.annotation.Nullable private OptionsUDP udp; + + public Listener() {} + + public Listener(String name) { + this(); + this.name = name; + } + + public Listener displayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Get displayName + * + * @return displayName + */ + @javax.annotation.Nullable public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + } + + /** + * Will be used to reference a listener and will replace display name in the future. Currently + * uses <protocol>-<port> as the name if no display name is given. + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public Listener port(@javax.annotation.Nullable Integer port) { + this.port = port; + return this; + } + + /** + * Port number where we listen for traffic minimum: 1 maximum: 65535 + * + * @return port + */ + @javax.annotation.Nullable public Integer getPort() { + return port; + } + + public void setPort(@javax.annotation.Nullable Integer port) { + this.port = port; + } + + public Listener protocol(@javax.annotation.Nullable ProtocolEnum protocol) { + this.protocol = protocol; + return this; + } + + /** + * Protocol is the highest network protocol we understand to load balance. Currently only + * PROTOCOL_TCP, PROTOCOL_TCP_PROXY and PROTOCOL_TLS_PASSTHROUGH are supported. + * + * @return protocol + */ + @javax.annotation.Nullable public ProtocolEnum getProtocol() { + return protocol; + } + + public void setProtocol(@javax.annotation.Nullable ProtocolEnum protocol) { + this.protocol = protocol; + } + + public Listener serverNameIndicators( + @javax.annotation.Nullable List serverNameIndicators) { + this.serverNameIndicators = serverNameIndicators; + return this; + } + + public Listener addServerNameIndicatorsItem(ServerNameIndicator serverNameIndicatorsItem) { + if (this.serverNameIndicators == null) { + this.serverNameIndicators = new ArrayList<>(); + } + this.serverNameIndicators.add(serverNameIndicatorsItem); + return this; + } + + /** + * Server Name Indicators config for domains to be routed to the desired target pool for this + * listener. + * + * @return serverNameIndicators + */ + @javax.annotation.Nullable public List getServerNameIndicators() { + return serverNameIndicators; + } + + public void setServerNameIndicators( + @javax.annotation.Nullable List serverNameIndicators) { + this.serverNameIndicators = serverNameIndicators; + } + + public Listener targetPool(@javax.annotation.Nullable String targetPool) { + this.targetPool = targetPool; + return this; + } + + /** + * Reference target pool by target pool name. + * + * @return targetPool + */ + @javax.annotation.Nullable public String getTargetPool() { + return targetPool; + } + + public void setTargetPool(@javax.annotation.Nullable String targetPool) { + this.targetPool = targetPool; + } + + public Listener tcp(@javax.annotation.Nullable OptionsTCP tcp) { + this.tcp = tcp; + return this; + } + + /** + * Get tcp + * + * @return tcp + */ + @javax.annotation.Nullable public OptionsTCP getTcp() { + return tcp; + } + + public void setTcp(@javax.annotation.Nullable OptionsTCP tcp) { + this.tcp = tcp; + } + + public Listener udp(@javax.annotation.Nullable OptionsUDP udp) { + this.udp = udp; + return this; + } + + /** + * Get udp + * + * @return udp + */ + @javax.annotation.Nullable public OptionsUDP getUdp() { + return udp; + } + + public void setUdp(@javax.annotation.Nullable OptionsUDP udp) { + this.udp = udp; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Listener listener = (Listener) o; + return Objects.equals(this.displayName, listener.displayName) + && Objects.equals(this.name, listener.name) + && Objects.equals(this.port, listener.port) + && Objects.equals(this.protocol, listener.protocol) + && Objects.equals(this.serverNameIndicators, listener.serverNameIndicators) + && Objects.equals(this.targetPool, listener.targetPool) + && Objects.equals(this.tcp, listener.tcp) + && Objects.equals(this.udp, listener.udp); + } + + @Override + public int hashCode() { + return Objects.hash( + displayName, name, port, protocol, serverNameIndicators, targetPool, tcp, udp); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Listener {\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" protocol: ").append(toIndentedString(protocol)).append("\n"); + sb.append(" serverNameIndicators: ") + .append(toIndentedString(serverNameIndicators)) + .append("\n"); + sb.append(" targetPool: ").append(toIndentedString(targetPool)).append("\n"); + sb.append(" tcp: ").append(toIndentedString(tcp)).append("\n"); + sb.append(" udp: ").append(toIndentedString(udp)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "displayName", + "name", + "port", + "protocol", + "serverNameIndicators", + "targetPool", + "tcp", + "udp")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Listener + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Listener.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Listener is not found in the empty JSON string", + Listener.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Listener.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `Listener` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) + && !jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("protocol") != null && !jsonObj.get("protocol").isJsonNull()) + && !jsonObj.get("protocol").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `protocol` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("protocol").toString())); + } + // validate the optional field `protocol` + if (jsonObj.get("protocol") != null && !jsonObj.get("protocol").isJsonNull()) { + ProtocolEnum.validateJsonElement(jsonObj.get("protocol")); + } + if (jsonObj.get("serverNameIndicators") != null + && !jsonObj.get("serverNameIndicators").isJsonNull()) { + JsonArray jsonArrayserverNameIndicators = + jsonObj.getAsJsonArray("serverNameIndicators"); + if (jsonArrayserverNameIndicators != null) { + // ensure the json data is an array + if (!jsonObj.get("serverNameIndicators").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `serverNameIndicators` to be an array in the JSON string but got `%s`", + jsonObj.get("serverNameIndicators").toString())); + } + + // validate the optional field `serverNameIndicators` (array) + for (int i = 0; i < jsonArrayserverNameIndicators.size(); i++) { + ServerNameIndicator.validateJsonElement(jsonArrayserverNameIndicators.get(i)); + } + ; + } + } + if ((jsonObj.get("targetPool") != null && !jsonObj.get("targetPool").isJsonNull()) + && !jsonObj.get("targetPool").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targetPool` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("targetPool").toString())); + } + // validate the optional field `tcp` + if (jsonObj.get("tcp") != null && !jsonObj.get("tcp").isJsonNull()) { + OptionsTCP.validateJsonElement(jsonObj.get("tcp")); + } + // validate the optional field `udp` + if (jsonObj.get("udp") != null && !jsonObj.get("udp").isJsonNull()) { + OptionsUDP.validateJsonElement(jsonObj.get("udp")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Listener.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Listener' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Listener.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Listener value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Listener read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of Listener given an JSON string + * + * @param jsonString JSON string + * @return An instance of Listener + * @throws IOException if the JSON string is invalid with respect to Listener + */ + public static Listener fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Listener.class); + } + + /** + * Convert an instance of Listener to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java new file mode 100644 index 0000000..ad755e8 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancer.java @@ -0,0 +1,840 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** LoadBalancer */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadBalancer { + public static final String SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT = + "disableTargetSecurityGroupAssignment"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT) + @javax.annotation.Nullable private Boolean disableTargetSecurityGroupAssignment; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_EXTERNAL_ADDRESS = "externalAddress"; + + @SerializedName(SERIALIZED_NAME_EXTERNAL_ADDRESS) + @javax.annotation.Nullable private String externalAddress; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + + @SerializedName(SERIALIZED_NAME_LISTENERS) + @javax.annotation.Nullable private List listeners = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP = + "loadBalancerSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup loadBalancerSecurityGroup; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_NETWORKS = "networks"; + + @SerializedName(SERIALIZED_NAME_NETWORKS) + @javax.annotation.Nullable private List networks = new ArrayList<>(); + + public static final String SERIALIZED_NAME_OPTIONS = "options"; + + @SerializedName(SERIALIZED_NAME_OPTIONS) + @javax.annotation.Nullable private LoadBalancerOptions options; + + public static final String SERIALIZED_NAME_PLAN_ID = "planId"; + + @SerializedName(SERIALIZED_NAME_PLAN_ID) + @javax.annotation.Nullable private String planId; + + public static final String SERIALIZED_NAME_PRIVATE_ADDRESS = "privateAddress"; + + @SerializedName(SERIALIZED_NAME_PRIVATE_ADDRESS) + @javax.annotation.Nullable private String privateAddress; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + /** Gets or Sets status */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"), + + STATUS_PENDING("STATUS_PENDING"), + + STATUS_READY("STATUS_READY"), + + STATUS_ERROR("STATUS_ERROR"), + + STATUS_TERMINATING("STATUS_TERMINATING"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable private StatusEnum status; + + public static final String SERIALIZED_NAME_TARGET_POOLS = "targetPools"; + + @SerializedName(SERIALIZED_NAME_TARGET_POOLS) + @javax.annotation.Nullable private List targetPools = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TARGET_SECURITY_GROUP = "targetSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_TARGET_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup targetSecurityGroup; + + public static final String SERIALIZED_NAME_VERSION = "version"; + + @SerializedName(SERIALIZED_NAME_VERSION) + @javax.annotation.Nullable private String version; + + public LoadBalancer() {} + + public LoadBalancer( + List errors, + SecurityGroup loadBalancerSecurityGroup, + String privateAddress, + String region, + StatusEnum status, + SecurityGroup targetSecurityGroup) { + this(); + this.errors = errors; + this.loadBalancerSecurityGroup = loadBalancerSecurityGroup; + this.privateAddress = privateAddress; + this.region = region; + this.status = status; + this.targetSecurityGroup = targetSecurityGroup; + } + + public LoadBalancer disableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + return this; + } + + /** + * Disable target security group assignemt to allow targets outside of the given network. + * Connectivity to targets need to be ensured by the customer, including routing and Security + * Groups (targetSecurityGroup can be assigned). Not changeable after creation. + * + * @return disableTargetSecurityGroupAssignment + */ + @javax.annotation.Nullable public Boolean getDisableTargetSecurityGroupAssignment() { + return disableTargetSecurityGroupAssignment; + } + + public void setDisableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + } + + /** + * Reports all errors a load balancer has. + * + * @return errors + */ + @javax.annotation.Nullable public List getErrors() { + return errors; + } + + public LoadBalancer externalAddress(@javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + return this; + } + + /** + * External load balancer IP address where this load balancer is exposed. Not changeable after + * creation. + * + * @return externalAddress + */ + @javax.annotation.Nullable public String getExternalAddress() { + return externalAddress; + } + + public void setExternalAddress(@javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + } + + public LoadBalancer labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public LoadBalancer putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 + * per LB. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end + * with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in + * between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage + * them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). + * Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes + * (-), underscores (_), dots (.), and alphanumerics in between. + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public LoadBalancer listeners(@javax.annotation.Nullable List listeners) { + this.listeners = listeners; + return this; + } + + public LoadBalancer addListenersItem(Listener listenersItem) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listenersItem); + return this; + } + + /** + * There is a maximum listener count of 20. Port and protocol limitations: - UDP listeners + * cannot have the same port. - TCP-derived listeners cannot have the same port. A TCP-derived + * listener is any listener that listens on a TCP port. As of now those are: TCP, TCP_PROXY, and + * PROTOCOL_TLS_PASSTHROUGH. The only exception is, if all listeners for the same port are + * PROTOCOL_TLS_PASSTHROUGH. - PROTOCOL_TLS_PASSTHROUGH listeners cannot have the same port and + * at least one common domain name. - PROTOCOL_TLS_PASSTHROUGH listeners can have the same + * domain name and different ports though (e.g. ports 443 and 8443 for domain example.com). - + * PROTOCOL_TLS_PASSTHROUGH listeners without a domain name serve as a default listener and you + * can have only one default listener. + * + * @return listeners + */ + @javax.annotation.Nullable public List getListeners() { + return listeners; + } + + public void setListeners(@javax.annotation.Nullable List listeners) { + this.listeners = listeners; + } + + /** + * Security Group permitting network traffic from the LoadBalancer to the targets. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return loadBalancerSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getLoadBalancerSecurityGroup() { + return loadBalancerSecurityGroup; + } + + public LoadBalancer name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Load balancer name. Not changeable after creation. + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public LoadBalancer networks(@javax.annotation.Nullable List networks) { + this.networks = networks; + return this; + } + + public LoadBalancer addNetworksItem(Network networksItem) { + if (this.networks == null) { + this.networks = new ArrayList<>(); + } + this.networks.add(networksItem); + return this; + } + + /** + * List of networks that listeners and targets reside in. Currently limited to one. Not + * changeable after creation. + * + * @return networks + */ + @javax.annotation.Nullable public List getNetworks() { + return networks; + } + + public void setNetworks(@javax.annotation.Nullable List networks) { + this.networks = networks; + } + + public LoadBalancer options(@javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + return this; + } + + /** + * Get options + * + * @return options + */ + @javax.annotation.Nullable public LoadBalancerOptions getOptions() { + return options; + } + + public void setOptions(@javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + } + + public LoadBalancer planId(@javax.annotation.Nullable String planId) { + this.planId = planId; + return this; + } + + /** + * Service Plan configures the size of the Load Balancer. Currently supported plans are p10, + * p50, p250 and p750. This list can change in the future where plan ids will be removed and new + * plans by added. That is the reason this is not an enum. + * + * @return planId + */ + @javax.annotation.Nullable public String getPlanId() { + return planId; + } + + public void setPlanId(@javax.annotation.Nullable String planId) { + this.planId = planId; + } + + /** + * Transient private load balancer IP address that can change any time. + * + * @return privateAddress + */ + @javax.annotation.Nullable public String getPrivateAddress() { + return privateAddress; + } + + /** + * Region of the LoadBalancer + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nullable public StatusEnum getStatus() { + return status; + } + + public LoadBalancer targetPools(@javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + return this; + } + + public LoadBalancer addTargetPoolsItem(TargetPool targetPoolsItem) { + if (this.targetPools == null) { + this.targetPools = new ArrayList<>(); + } + this.targetPools.add(targetPoolsItem); + return this; + } + + /** + * List of all target pools which will be used in the load balancer. Limited to 20. + * + * @return targetPools + */ + @javax.annotation.Nullable public List getTargetPools() { + return targetPools; + } + + public void setTargetPools(@javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + } + + /** + * Security Group that allows the targets to receive traffic from the LoadBalancer. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return targetSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getTargetSecurityGroup() { + return targetSecurityGroup; + } + + public LoadBalancer version(@javax.annotation.Nullable String version) { + this.version = version; + return this; + } + + /** + * Load balancer resource version. Must be empty or unset for creating load balancers, non-empty + * for updating load balancers. Semantics: While retrieving load balancers, this is the current + * version of this load balancer resource that changes during updates of the load balancers. On + * updates this field specified the load balancer version you calculated your update for instead + * of the future version to enable concurrency safe updates. Update calls will then report the + * new version in their result as you would see with a load balancer retrieval call later. There + * exist no total order of the version, so you can only compare it for equality, but not for + * less/greater than another version. Since the creation of load balancer is always intended to + * create the first version of it, there should be no existing version. That's why this + * field must by empty of not present in that case. + * + * @return version + */ + @javax.annotation.Nullable public String getVersion() { + return version; + } + + public void setVersion(@javax.annotation.Nullable String version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadBalancer loadBalancer = (LoadBalancer) o; + return Objects.equals( + this.disableTargetSecurityGroupAssignment, + loadBalancer.disableTargetSecurityGroupAssignment) + && Objects.equals(this.errors, loadBalancer.errors) + && Objects.equals(this.externalAddress, loadBalancer.externalAddress) + && Objects.equals(this.labels, loadBalancer.labels) + && Objects.equals(this.listeners, loadBalancer.listeners) + && Objects.equals( + this.loadBalancerSecurityGroup, loadBalancer.loadBalancerSecurityGroup) + && Objects.equals(this.name, loadBalancer.name) + && Objects.equals(this.networks, loadBalancer.networks) + && Objects.equals(this.options, loadBalancer.options) + && Objects.equals(this.planId, loadBalancer.planId) + && Objects.equals(this.privateAddress, loadBalancer.privateAddress) + && Objects.equals(this.region, loadBalancer.region) + && Objects.equals(this.status, loadBalancer.status) + && Objects.equals(this.targetPools, loadBalancer.targetPools) + && Objects.equals(this.targetSecurityGroup, loadBalancer.targetSecurityGroup) + && Objects.equals(this.version, loadBalancer.version); + } + + @Override + public int hashCode() { + return Objects.hash( + disableTargetSecurityGroupAssignment, + errors, + externalAddress, + labels, + listeners, + loadBalancerSecurityGroup, + name, + networks, + options, + planId, + privateAddress, + region, + status, + targetPools, + targetSecurityGroup, + version); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadBalancer {\n"); + sb.append(" disableTargetSecurityGroupAssignment: ") + .append(toIndentedString(disableTargetSecurityGroupAssignment)) + .append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" externalAddress: ").append(toIndentedString(externalAddress)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); + sb.append(" loadBalancerSecurityGroup: ") + .append(toIndentedString(loadBalancerSecurityGroup)) + .append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" networks: ").append(toIndentedString(networks)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append(" planId: ").append(toIndentedString(planId)).append("\n"); + sb.append(" privateAddress: ").append(toIndentedString(privateAddress)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" targetPools: ").append(toIndentedString(targetPools)).append("\n"); + sb.append(" targetSecurityGroup: ") + .append(toIndentedString(targetSecurityGroup)) + .append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "disableTargetSecurityGroupAssignment", + "errors", + "externalAddress", + "labels", + "listeners", + "loadBalancerSecurityGroup", + "name", + "networks", + "options", + "planId", + "privateAddress", + "region", + "status", + "targetPools", + "targetSecurityGroup", + "version")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to LoadBalancer + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadBalancer.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadBalancer is not found in the empty JSON string", + LoadBalancer.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadBalancer.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadBalancer` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `errors` to be an array in the JSON string but got `%s`", + jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + LoadBalancerError.validateJsonElement(jsonArrayerrors.get(i)); + } + ; + } + } + if ((jsonObj.get("externalAddress") != null && !jsonObj.get("externalAddress").isJsonNull()) + && !jsonObj.get("externalAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `externalAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("externalAddress").toString())); + } + if (jsonObj.get("listeners") != null && !jsonObj.get("listeners").isJsonNull()) { + JsonArray jsonArraylisteners = jsonObj.getAsJsonArray("listeners"); + if (jsonArraylisteners != null) { + // ensure the json data is an array + if (!jsonObj.get("listeners").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `listeners` to be an array in the JSON string but got `%s`", + jsonObj.get("listeners").toString())); + } + + // validate the optional field `listeners` (array) + for (int i = 0; i < jsonArraylisteners.size(); i++) { + Listener.validateJsonElement(jsonArraylisteners.get(i)); + } + ; + } + } + // validate the optional field `loadBalancerSecurityGroup` + if (jsonObj.get("loadBalancerSecurityGroup") != null + && !jsonObj.get("loadBalancerSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("loadBalancerSecurityGroup")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (jsonObj.get("networks") != null && !jsonObj.get("networks").isJsonNull()) { + JsonArray jsonArraynetworks = jsonObj.getAsJsonArray("networks"); + if (jsonArraynetworks != null) { + // ensure the json data is an array + if (!jsonObj.get("networks").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `networks` to be an array in the JSON string but got `%s`", + jsonObj.get("networks").toString())); + } + + // validate the optional field `networks` (array) + for (int i = 0; i < jsonArraynetworks.size(); i++) { + Network.validateJsonElement(jsonArraynetworks.get(i)); + } + ; + } + } + // validate the optional field `options` + if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { + LoadBalancerOptions.validateJsonElement(jsonObj.get("options")); + } + if ((jsonObj.get("planId") != null && !jsonObj.get("planId").isJsonNull()) + && !jsonObj.get("planId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `planId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("planId").toString())); + } + if ((jsonObj.get("privateAddress") != null && !jsonObj.get("privateAddress").isJsonNull()) + && !jsonObj.get("privateAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `privateAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("privateAddress").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) + && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `status` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("status").toString())); + } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + if (jsonObj.get("targetPools") != null && !jsonObj.get("targetPools").isJsonNull()) { + JsonArray jsonArraytargetPools = jsonObj.getAsJsonArray("targetPools"); + if (jsonArraytargetPools != null) { + // ensure the json data is an array + if (!jsonObj.get("targetPools").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targetPools` to be an array in the JSON string but got `%s`", + jsonObj.get("targetPools").toString())); + } + + // validate the optional field `targetPools` (array) + for (int i = 0; i < jsonArraytargetPools.size(); i++) { + TargetPool.validateJsonElement(jsonArraytargetPools.get(i)); + } + ; + } + } + // validate the optional field `targetSecurityGroup` + if (jsonObj.get("targetSecurityGroup") != null + && !jsonObj.get("targetSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("targetSecurityGroup")); + } + if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) + && !jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `version` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("version").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadBalancer.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadBalancer' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(LoadBalancer.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadBalancer value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadBalancer read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadBalancer given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadBalancer + * @throws IOException if the JSON string is invalid with respect to LoadBalancer + */ + public static LoadBalancer fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadBalancer.class); + } + + /** + * Convert an instance of LoadBalancer to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java new file mode 100644 index 0000000..d854bf7 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerError.java @@ -0,0 +1,313 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** LoadBalancerError */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadBalancerError { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + /** + * The error type specifies which part of the load balancer encountered the error. I.e. the API + * will not check if a provided public IP is actually available in the project. Instead the load + * balancer with try to use the provided IP and if not available reports TYPE_FIP_NOT_CONFIGURED + * error or TYPE_FIP_NOT_FOUND if the IP was deleted. + */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + TYPE_UNSPECIFIED("TYPE_UNSPECIFIED"), + + TYPE_INTERNAL("TYPE_INTERNAL"), + + TYPE_QUOTA_SECGROUP_EXCEEDED("TYPE_QUOTA_SECGROUP_EXCEEDED"), + + TYPE_QUOTA_SECGROUPRULE_EXCEEDED("TYPE_QUOTA_SECGROUPRULE_EXCEEDED"), + + TYPE_PORT_NOT_CONFIGURED("TYPE_PORT_NOT_CONFIGURED"), + + TYPE_FIP_NOT_CONFIGURED("TYPE_FIP_NOT_CONFIGURED"), + + TYPE_TARGET_NOT_ACTIVE("TYPE_TARGET_NOT_ACTIVE"), + + TYPE_METRICS_MISCONFIGURED("TYPE_METRICS_MISCONFIGURED"), + + TYPE_LOGS_MISCONFIGURED("TYPE_LOGS_MISCONFIGURED"), + + TYPE_FIP_NOT_FOUND("TYPE_FIP_NOT_FOUND"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + TypeEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nullable private TypeEnum type; + + public LoadBalancerError() {} + + public LoadBalancerError description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * The error description contains additional helpful user information to fix the error state of + * the load balancer. For example the IP 45.135.247.139 does not exist in the project, then the + * description will report: Floating IP \"45.135.247.139\" could not be found or if + * the IP was deleted then you will get a proper error message. + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public LoadBalancerError type(@javax.annotation.Nullable TypeEnum type) { + this.type = type; + return this; + } + + /** + * The error type specifies which part of the load balancer encountered the error. I.e. the API + * will not check if a provided public IP is actually available in the project. Instead the load + * balancer with try to use the provided IP and if not available reports TYPE_FIP_NOT_CONFIGURED + * error or TYPE_FIP_NOT_FOUND if the IP was deleted. + * + * @return type + */ + @javax.annotation.Nullable public TypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nullable TypeEnum type) { + this.type = type; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadBalancerError loadBalancerError = (LoadBalancerError) o; + return Objects.equals(this.description, loadBalancerError.description) + && Objects.equals(this.type, loadBalancerError.type); + } + + @Override + public int hashCode() { + return Objects.hash(description, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadBalancerError {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("description", "type")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to LoadBalancerError + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadBalancerError.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadBalancerError is not found in the empty JSON string", + LoadBalancerError.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadBalancerError.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadBalancerError` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) + && !jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `type` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("type").toString())); + } + // validate the optional field `type` + if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) { + TypeEnum.validateJsonElement(jsonObj.get("type")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadBalancerError.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadBalancerError' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(LoadBalancerError.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadBalancerError value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadBalancerError read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadBalancerError given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadBalancerError + * @throws IOException if the JSON string is invalid with respect to LoadBalancerError + */ + public static LoadBalancerError fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadBalancerError.class); + } + + /** + * Convert an instance of LoadBalancerError to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java new file mode 100644 index 0000000..e359190 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadBalancerOptions.java @@ -0,0 +1,287 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Defines any optional functionality you want to have enabled on your load balancer. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadBalancerOptions { + public static final String SERIALIZED_NAME_ACCESS_CONTROL = "accessControl"; + + @SerializedName(SERIALIZED_NAME_ACCESS_CONTROL) + @javax.annotation.Nullable private LoadbalancerOptionAccessControl accessControl; + + public static final String SERIALIZED_NAME_EPHEMERAL_ADDRESS = "ephemeralAddress"; + + @SerializedName(SERIALIZED_NAME_EPHEMERAL_ADDRESS) + @javax.annotation.Nullable private Boolean ephemeralAddress; + + public static final String SERIALIZED_NAME_OBSERVABILITY = "observability"; + + @SerializedName(SERIALIZED_NAME_OBSERVABILITY) + @javax.annotation.Nullable private LoadbalancerOptionObservability observability; + + public static final String SERIALIZED_NAME_PRIVATE_NETWORK_ONLY = "privateNetworkOnly"; + + @SerializedName(SERIALIZED_NAME_PRIVATE_NETWORK_ONLY) + @javax.annotation.Nullable private Boolean privateNetworkOnly; + + public LoadBalancerOptions() {} + + public LoadBalancerOptions accessControl( + @javax.annotation.Nullable LoadbalancerOptionAccessControl accessControl) { + this.accessControl = accessControl; + return this; + } + + /** + * Get accessControl + * + * @return accessControl + */ + @javax.annotation.Nullable public LoadbalancerOptionAccessControl getAccessControl() { + return accessControl; + } + + public void setAccessControl( + @javax.annotation.Nullable LoadbalancerOptionAccessControl accessControl) { + this.accessControl = accessControl; + } + + public LoadBalancerOptions ephemeralAddress( + @javax.annotation.Nullable Boolean ephemeralAddress) { + this.ephemeralAddress = ephemeralAddress; + return this; + } + + /** + * Get ephemeralAddress + * + * @return ephemeralAddress + */ + @javax.annotation.Nullable public Boolean getEphemeralAddress() { + return ephemeralAddress; + } + + public void setEphemeralAddress(@javax.annotation.Nullable Boolean ephemeralAddress) { + this.ephemeralAddress = ephemeralAddress; + } + + public LoadBalancerOptions observability( + @javax.annotation.Nullable LoadbalancerOptionObservability observability) { + this.observability = observability; + return this; + } + + /** + * Get observability + * + * @return observability + */ + @javax.annotation.Nullable public LoadbalancerOptionObservability getObservability() { + return observability; + } + + public void setObservability( + @javax.annotation.Nullable LoadbalancerOptionObservability observability) { + this.observability = observability; + } + + public LoadBalancerOptions privateNetworkOnly( + @javax.annotation.Nullable Boolean privateNetworkOnly) { + this.privateNetworkOnly = privateNetworkOnly; + return this; + } + + /** + * Load Balancer is accessible only via a private network ip address. Not changeable after + * creation. + * + * @return privateNetworkOnly + */ + @javax.annotation.Nullable public Boolean getPrivateNetworkOnly() { + return privateNetworkOnly; + } + + public void setPrivateNetworkOnly(@javax.annotation.Nullable Boolean privateNetworkOnly) { + this.privateNetworkOnly = privateNetworkOnly; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadBalancerOptions loadBalancerOptions = (LoadBalancerOptions) o; + return Objects.equals(this.accessControl, loadBalancerOptions.accessControl) + && Objects.equals(this.ephemeralAddress, loadBalancerOptions.ephemeralAddress) + && Objects.equals(this.observability, loadBalancerOptions.observability) + && Objects.equals(this.privateNetworkOnly, loadBalancerOptions.privateNetworkOnly); + } + + @Override + public int hashCode() { + return Objects.hash(accessControl, ephemeralAddress, observability, privateNetworkOnly); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadBalancerOptions {\n"); + sb.append(" accessControl: ").append(toIndentedString(accessControl)).append("\n"); + sb.append(" ephemeralAddress: ").append(toIndentedString(ephemeralAddress)).append("\n"); + sb.append(" observability: ").append(toIndentedString(observability)).append("\n"); + sb.append(" privateNetworkOnly: ") + .append(toIndentedString(privateNetworkOnly)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "accessControl", + "ephemeralAddress", + "observability", + "privateNetworkOnly")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to LoadBalancerOptions + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadBalancerOptions.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadBalancerOptions is not found in the empty JSON string", + LoadBalancerOptions.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadBalancerOptions.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadBalancerOptions` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `accessControl` + if (jsonObj.get("accessControl") != null && !jsonObj.get("accessControl").isJsonNull()) { + LoadbalancerOptionAccessControl.validateJsonElement(jsonObj.get("accessControl")); + } + // validate the optional field `observability` + if (jsonObj.get("observability") != null && !jsonObj.get("observability").isJsonNull()) { + LoadbalancerOptionObservability.validateJsonElement(jsonObj.get("observability")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadBalancerOptions.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadBalancerOptions' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(LoadBalancerOptions.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadBalancerOptions value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadBalancerOptions read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadBalancerOptions given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadBalancerOptions + * @throws IOException if the JSON string is invalid with respect to LoadBalancerOptions + */ + public static LoadBalancerOptions fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadBalancerOptions.class); + } + + /** + * Convert an instance of LoadBalancerOptions to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java new file mode 100644 index 0000000..2590701 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionAccessControl.java @@ -0,0 +1,220 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Use this option to limit the IP ranges that can use the load balancer. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadbalancerOptionAccessControl { + public static final String SERIALIZED_NAME_ALLOWED_SOURCE_RANGES = "allowedSourceRanges"; + + @SerializedName(SERIALIZED_NAME_ALLOWED_SOURCE_RANGES) + @javax.annotation.Nullable private List allowedSourceRanges = new ArrayList<>(); + + public LoadbalancerOptionAccessControl() {} + + public LoadbalancerOptionAccessControl allowedSourceRanges( + @javax.annotation.Nullable List allowedSourceRanges) { + this.allowedSourceRanges = allowedSourceRanges; + return this; + } + + public LoadbalancerOptionAccessControl addAllowedSourceRangesItem( + String allowedSourceRangesItem) { + if (this.allowedSourceRanges == null) { + this.allowedSourceRanges = new ArrayList<>(); + } + this.allowedSourceRanges.add(allowedSourceRangesItem); + return this; + } + + /** + * Load Balancer is accessible only from an IP address in this range + * + * @return allowedSourceRanges + */ + @javax.annotation.Nullable public List getAllowedSourceRanges() { + return allowedSourceRanges; + } + + public void setAllowedSourceRanges( + @javax.annotation.Nullable List allowedSourceRanges) { + this.allowedSourceRanges = allowedSourceRanges; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadbalancerOptionAccessControl loadbalancerOptionAccessControl = + (LoadbalancerOptionAccessControl) o; + return Objects.equals( + this.allowedSourceRanges, loadbalancerOptionAccessControl.allowedSourceRanges); + } + + @Override + public int hashCode() { + return Objects.hash(allowedSourceRanges); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadbalancerOptionAccessControl {\n"); + sb.append(" allowedSourceRanges: ") + .append(toIndentedString(allowedSourceRanges)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("allowedSourceRanges")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * LoadbalancerOptionAccessControl + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadbalancerOptionAccessControl.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadbalancerOptionAccessControl is not found in the empty JSON string", + LoadbalancerOptionAccessControl.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadbalancerOptionAccessControl.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionAccessControl` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("allowedSourceRanges") != null + && !jsonObj.get("allowedSourceRanges").isJsonNull() + && !jsonObj.get("allowedSourceRanges").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `allowedSourceRanges` to be an array in the JSON string but got `%s`", + jsonObj.get("allowedSourceRanges").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadbalancerOptionAccessControl.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadbalancerOptionAccessControl' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LoadbalancerOptionAccessControl.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadbalancerOptionAccessControl value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadbalancerOptionAccessControl read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadbalancerOptionAccessControl given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadbalancerOptionAccessControl + * @throws IOException if the JSON string is invalid with respect to + * LoadbalancerOptionAccessControl + */ + public static LoadbalancerOptionAccessControl fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadbalancerOptionAccessControl.class); + } + + /** + * Convert an instance of LoadbalancerOptionAccessControl to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java new file mode 100644 index 0000000..a6c397b --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionLogs.java @@ -0,0 +1,231 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** LoadbalancerOptionLogs */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadbalancerOptionLogs { + public static final String SERIALIZED_NAME_CREDENTIALS_REF = "credentialsRef"; + + @SerializedName(SERIALIZED_NAME_CREDENTIALS_REF) + @javax.annotation.Nullable private String credentialsRef; + + public static final String SERIALIZED_NAME_PUSH_URL = "pushUrl"; + + @SerializedName(SERIALIZED_NAME_PUSH_URL) + @javax.annotation.Nullable private String pushUrl; + + public LoadbalancerOptionLogs() {} + + public LoadbalancerOptionLogs credentialsRef(@javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + return this; + } + + /** + * Credentials reference for logging. This reference is created via the observability create + * endpoint and the credential needs to contain the basic auth username and password for the + * logging solution the push URL points to. Then this enables monitoring via remote write for + * the Load Balancer. + * + * @return credentialsRef + */ + @javax.annotation.Nullable public String getCredentialsRef() { + return credentialsRef; + } + + public void setCredentialsRef(@javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + } + + public LoadbalancerOptionLogs pushUrl(@javax.annotation.Nullable String pushUrl) { + this.pushUrl = pushUrl; + return this; + } + + /** + * The Observability(Logs)/Loki remote write Push URL you want the logs to be shipped to. + * + * @return pushUrl + */ + @javax.annotation.Nullable public String getPushUrl() { + return pushUrl; + } + + public void setPushUrl(@javax.annotation.Nullable String pushUrl) { + this.pushUrl = pushUrl; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadbalancerOptionLogs loadbalancerOptionLogs = (LoadbalancerOptionLogs) o; + return Objects.equals(this.credentialsRef, loadbalancerOptionLogs.credentialsRef) + && Objects.equals(this.pushUrl, loadbalancerOptionLogs.pushUrl); + } + + @Override + public int hashCode() { + return Objects.hash(credentialsRef, pushUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadbalancerOptionLogs {\n"); + sb.append(" credentialsRef: ").append(toIndentedString(credentialsRef)).append("\n"); + sb.append(" pushUrl: ").append(toIndentedString(pushUrl)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credentialsRef", "pushUrl")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to LoadbalancerOptionLogs + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadbalancerOptionLogs.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadbalancerOptionLogs is not found in the empty JSON string", + LoadbalancerOptionLogs.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadbalancerOptionLogs.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionLogs` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) + && !jsonObj.get("credentialsRef").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `credentialsRef` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("credentialsRef").toString())); + } + if ((jsonObj.get("pushUrl") != null && !jsonObj.get("pushUrl").isJsonNull()) + && !jsonObj.get("pushUrl").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushUrl` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("pushUrl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadbalancerOptionLogs.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadbalancerOptionLogs' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(LoadbalancerOptionLogs.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadbalancerOptionLogs value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadbalancerOptionLogs read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadbalancerOptionLogs given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadbalancerOptionLogs + * @throws IOException if the JSON string is invalid with respect to LoadbalancerOptionLogs + */ + public static LoadbalancerOptionLogs fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadbalancerOptionLogs.class); + } + + /** + * Convert an instance of LoadbalancerOptionLogs to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java new file mode 100644 index 0000000..b19673b --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionMetrics.java @@ -0,0 +1,234 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** LoadbalancerOptionMetrics */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadbalancerOptionMetrics { + public static final String SERIALIZED_NAME_CREDENTIALS_REF = "credentialsRef"; + + @SerializedName(SERIALIZED_NAME_CREDENTIALS_REF) + @javax.annotation.Nullable private String credentialsRef; + + public static final String SERIALIZED_NAME_PUSH_URL = "pushUrl"; + + @SerializedName(SERIALIZED_NAME_PUSH_URL) + @javax.annotation.Nullable private String pushUrl; + + public LoadbalancerOptionMetrics() {} + + public LoadbalancerOptionMetrics credentialsRef( + @javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + return this; + } + + /** + * Credentials reference for metrics. This reference is created via the observability create + * endpoint and the credential needs to contain the basic auth username and password for the + * metrics solution the push URL points to. Then this enables monitoring via remote write for + * the Load Balancer. + * + * @return credentialsRef + */ + @javax.annotation.Nullable public String getCredentialsRef() { + return credentialsRef; + } + + public void setCredentialsRef(@javax.annotation.Nullable String credentialsRef) { + this.credentialsRef = credentialsRef; + } + + public LoadbalancerOptionMetrics pushUrl(@javax.annotation.Nullable String pushUrl) { + this.pushUrl = pushUrl; + return this; + } + + /** + * The Observability(Metrics)/Prometheus remote write push URL you want the metrics to be + * shipped to. + * + * @return pushUrl + */ + @javax.annotation.Nullable public String getPushUrl() { + return pushUrl; + } + + public void setPushUrl(@javax.annotation.Nullable String pushUrl) { + this.pushUrl = pushUrl; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadbalancerOptionMetrics loadbalancerOptionMetrics = (LoadbalancerOptionMetrics) o; + return Objects.equals(this.credentialsRef, loadbalancerOptionMetrics.credentialsRef) + && Objects.equals(this.pushUrl, loadbalancerOptionMetrics.pushUrl); + } + + @Override + public int hashCode() { + return Objects.hash(credentialsRef, pushUrl); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadbalancerOptionMetrics {\n"); + sb.append(" credentialsRef: ").append(toIndentedString(credentialsRef)).append("\n"); + sb.append(" pushUrl: ").append(toIndentedString(pushUrl)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credentialsRef", "pushUrl")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to LoadbalancerOptionMetrics + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadbalancerOptionMetrics.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadbalancerOptionMetrics is not found in the empty JSON string", + LoadbalancerOptionMetrics.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadbalancerOptionMetrics.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionMetrics` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("credentialsRef") != null && !jsonObj.get("credentialsRef").isJsonNull()) + && !jsonObj.get("credentialsRef").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `credentialsRef` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("credentialsRef").toString())); + } + if ((jsonObj.get("pushUrl") != null && !jsonObj.get("pushUrl").isJsonNull()) + && !jsonObj.get("pushUrl").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `pushUrl` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("pushUrl").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadbalancerOptionMetrics.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadbalancerOptionMetrics' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(LoadbalancerOptionMetrics.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadbalancerOptionMetrics value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadbalancerOptionMetrics read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadbalancerOptionMetrics given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadbalancerOptionMetrics + * @throws IOException if the JSON string is invalid with respect to LoadbalancerOptionMetrics + */ + public static LoadbalancerOptionMetrics fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadbalancerOptionMetrics.class); + } + + /** + * Convert an instance of LoadbalancerOptionMetrics to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java new file mode 100644 index 0000000..5d4c752 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/LoadbalancerOptionObservability.java @@ -0,0 +1,230 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** We offer Load Balancer observability via STACKIT Observability or external solutions. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class LoadbalancerOptionObservability { + public static final String SERIALIZED_NAME_LOGS = "logs"; + + @SerializedName(SERIALIZED_NAME_LOGS) + @javax.annotation.Nullable private LoadbalancerOptionLogs logs; + + public static final String SERIALIZED_NAME_METRICS = "metrics"; + + @SerializedName(SERIALIZED_NAME_METRICS) + @javax.annotation.Nullable private LoadbalancerOptionMetrics metrics; + + public LoadbalancerOptionObservability() {} + + public LoadbalancerOptionObservability logs( + @javax.annotation.Nullable LoadbalancerOptionLogs logs) { + this.logs = logs; + return this; + } + + /** + * Get logs + * + * @return logs + */ + @javax.annotation.Nullable public LoadbalancerOptionLogs getLogs() { + return logs; + } + + public void setLogs(@javax.annotation.Nullable LoadbalancerOptionLogs logs) { + this.logs = logs; + } + + public LoadbalancerOptionObservability metrics( + @javax.annotation.Nullable LoadbalancerOptionMetrics metrics) { + this.metrics = metrics; + return this; + } + + /** + * Get metrics + * + * @return metrics + */ + @javax.annotation.Nullable public LoadbalancerOptionMetrics getMetrics() { + return metrics; + } + + public void setMetrics(@javax.annotation.Nullable LoadbalancerOptionMetrics metrics) { + this.metrics = metrics; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LoadbalancerOptionObservability loadbalancerOptionObservability = + (LoadbalancerOptionObservability) o; + return Objects.equals(this.logs, loadbalancerOptionObservability.logs) + && Objects.equals(this.metrics, loadbalancerOptionObservability.metrics); + } + + @Override + public int hashCode() { + return Objects.hash(logs, metrics); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LoadbalancerOptionObservability {\n"); + sb.append(" logs: ").append(toIndentedString(logs)).append("\n"); + sb.append(" metrics: ").append(toIndentedString(metrics)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("logs", "metrics")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to + * LoadbalancerOptionObservability + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!LoadbalancerOptionObservability.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in LoadbalancerOptionObservability is not found in the empty JSON string", + LoadbalancerOptionObservability.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!LoadbalancerOptionObservability.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `LoadbalancerOptionObservability` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `logs` + if (jsonObj.get("logs") != null && !jsonObj.get("logs").isJsonNull()) { + LoadbalancerOptionLogs.validateJsonElement(jsonObj.get("logs")); + } + // validate the optional field `metrics` + if (jsonObj.get("metrics") != null && !jsonObj.get("metrics").isJsonNull()) { + LoadbalancerOptionMetrics.validateJsonElement(jsonObj.get("metrics")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!LoadbalancerOptionObservability.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'LoadbalancerOptionObservability' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter( + this, TypeToken.get(LoadbalancerOptionObservability.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, LoadbalancerOptionObservability value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public LoadbalancerOptionObservability read(JsonReader in) + throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of LoadbalancerOptionObservability given an JSON string + * + * @param jsonString JSON string + * @return An instance of LoadbalancerOptionObservability + * @throws IOException if the JSON string is invalid with respect to + * LoadbalancerOptionObservability + */ + public static LoadbalancerOptionObservability fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, LoadbalancerOptionObservability.class); + } + + /** + * Convert an instance of LoadbalancerOptionObservability to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java new file mode 100644 index 0000000..ad535cd --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Network.java @@ -0,0 +1,294 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; + +/** Network */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Network { + public static final String SERIALIZED_NAME_NETWORK_ID = "networkId"; + + @SerializedName(SERIALIZED_NAME_NETWORK_ID) + @javax.annotation.Nullable private UUID networkId; + + /** + * The role defines how the load balancer is using the network. Currently only + * ROLE_LISTENERS_AND_TARGETS is supported. + */ + @JsonAdapter(RoleEnum.Adapter.class) + public enum RoleEnum { + ROLE_UNSPECIFIED("ROLE_UNSPECIFIED"), + + ROLE_LISTENERS_AND_TARGETS("ROLE_LISTENERS_AND_TARGETS"), + + ROLE_LISTENERS("ROLE_LISTENERS"), + + ROLE_TARGETS("ROLE_TARGETS"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + RoleEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RoleEnum fromValue(String value) { + for (RoleEnum b : RoleEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final RoleEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RoleEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return RoleEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + RoleEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_ROLE = "role"; + + @SerializedName(SERIALIZED_NAME_ROLE) + @javax.annotation.Nullable private RoleEnum role; + + public Network() {} + + public Network networkId(@javax.annotation.Nullable UUID networkId) { + this.networkId = networkId; + return this; + } + + /** + * Openstack network ID + * + * @return networkId + */ + @javax.annotation.Nullable public UUID getNetworkId() { + return networkId; + } + + public void setNetworkId(@javax.annotation.Nullable UUID networkId) { + this.networkId = networkId; + } + + public Network role(@javax.annotation.Nullable RoleEnum role) { + this.role = role; + return this; + } + + /** + * The role defines how the load balancer is using the network. Currently only + * ROLE_LISTENERS_AND_TARGETS is supported. + * + * @return role + */ + @javax.annotation.Nullable public RoleEnum getRole() { + return role; + } + + public void setRole(@javax.annotation.Nullable RoleEnum role) { + this.role = role; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Network network = (Network) o; + return Objects.equals(this.networkId, network.networkId) + && Objects.equals(this.role, network.role); + } + + @Override + public int hashCode() { + return Objects.hash(networkId, role); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Network {\n"); + sb.append(" networkId: ").append(toIndentedString(networkId)).append("\n"); + sb.append(" role: ").append(toIndentedString(role)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("networkId", "role")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Network + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Network.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Network is not found in the empty JSON string", + Network.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Network.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `Network` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("networkId") != null && !jsonObj.get("networkId").isJsonNull()) + && !jsonObj.get("networkId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `networkId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("networkId").toString())); + } + if ((jsonObj.get("role") != null && !jsonObj.get("role").isJsonNull()) + && !jsonObj.get("role").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `role` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("role").toString())); + } + // validate the optional field `role` + if (jsonObj.get("role") != null && !jsonObj.get("role").isJsonNull()) { + RoleEnum.validateJsonElement(jsonObj.get("role")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Network.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Network' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Network.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Network value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Network read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of Network given an JSON string + * + * @param jsonString JSON string + * @return An instance of Network + * @throws IOException if the JSON string is invalid with respect to Network + */ + public static Network fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Network.class); + } + + /** + * Convert an instance of Network to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java new file mode 100644 index 0000000..3418f96 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsTCP.java @@ -0,0 +1,200 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * ProtocolOptionsTCP options to be configured for the PROTOCOL_TCP, PROTOCOL_TCP_PROXY, and + * PROTOCOL_TLS_PASSTHROUGH protocols. TCP options for the SNI listeners with the same port must be + * the same. + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class OptionsTCP { + public static final String SERIALIZED_NAME_IDLE_TIMEOUT = "idleTimeout"; + + @SerializedName(SERIALIZED_NAME_IDLE_TIMEOUT) + @javax.annotation.Nullable private String idleTimeout; + + public OptionsTCP() {} + + public OptionsTCP idleTimeout(@javax.annotation.Nullable String idleTimeout) { + this.idleTimeout = idleTimeout; + return this; + } + + /** + * The connection idle timeout to be used with the protocol. The default value is set to 5 + * minutes, and the maximum value is one hour. + * + * @return idleTimeout + */ + @javax.annotation.Nullable public String getIdleTimeout() { + return idleTimeout; + } + + public void setIdleTimeout(@javax.annotation.Nullable String idleTimeout) { + this.idleTimeout = idleTimeout; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OptionsTCP optionsTCP = (OptionsTCP) o; + return Objects.equals(this.idleTimeout, optionsTCP.idleTimeout); + } + + @Override + public int hashCode() { + return Objects.hash(idleTimeout); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OptionsTCP {\n"); + sb.append(" idleTimeout: ").append(toIndentedString(idleTimeout)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("idleTimeout")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OptionsTCP + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OptionsTCP.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in OptionsTCP is not found in the empty JSON string", + OptionsTCP.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!OptionsTCP.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `OptionsTCP` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("idleTimeout") != null && !jsonObj.get("idleTimeout").isJsonNull()) + && !jsonObj.get("idleTimeout").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `idleTimeout` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("idleTimeout").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OptionsTCP.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OptionsTCP' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(OptionsTCP.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, OptionsTCP value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OptionsTCP read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of OptionsTCP given an JSON string + * + * @param jsonString JSON string + * @return An instance of OptionsTCP + * @throws IOException if the JSON string is invalid with respect to OptionsTCP + */ + public static OptionsTCP fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OptionsTCP.class); + } + + /** + * Convert an instance of OptionsTCP to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java new file mode 100644 index 0000000..9718f5f --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/OptionsUDP.java @@ -0,0 +1,196 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ProtocolOptionsUDP options to be configured for the PROTOCOL_UDP protocol. */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class OptionsUDP { + public static final String SERIALIZED_NAME_IDLE_TIMEOUT = "idleTimeout"; + + @SerializedName(SERIALIZED_NAME_IDLE_TIMEOUT) + @javax.annotation.Nullable private String idleTimeout; + + public OptionsUDP() {} + + public OptionsUDP idleTimeout(@javax.annotation.Nullable String idleTimeout) { + this.idleTimeout = idleTimeout; + return this; + } + + /** + * The connection idle timeout to be used with the protocol. The default value is set to 1 + * minute, and the maximum value is 2 minutes. + * + * @return idleTimeout + */ + @javax.annotation.Nullable public String getIdleTimeout() { + return idleTimeout; + } + + public void setIdleTimeout(@javax.annotation.Nullable String idleTimeout) { + this.idleTimeout = idleTimeout; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OptionsUDP optionsUDP = (OptionsUDP) o; + return Objects.equals(this.idleTimeout, optionsUDP.idleTimeout); + } + + @Override + public int hashCode() { + return Objects.hash(idleTimeout); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OptionsUDP {\n"); + sb.append(" idleTimeout: ").append(toIndentedString(idleTimeout)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("idleTimeout")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to OptionsUDP + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!OptionsUDP.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in OptionsUDP is not found in the empty JSON string", + OptionsUDP.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!OptionsUDP.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `OptionsUDP` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("idleTimeout") != null && !jsonObj.get("idleTimeout").isJsonNull()) + && !jsonObj.get("idleTimeout").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `idleTimeout` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("idleTimeout").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!OptionsUDP.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'OptionsUDP' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(OptionsUDP.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, OptionsUDP value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public OptionsUDP read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of OptionsUDP given an JSON string + * + * @param jsonString JSON string + * @return An instance of OptionsUDP + * @throws IOException if the JSON string is invalid with respect to OptionsUDP + */ + public static OptionsUDP fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, OptionsUDP.class); + } + + /** + * Convert an instance of OptionsUDP to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java new file mode 100644 index 0000000..556f379 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/PlanDetails.java @@ -0,0 +1,356 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** PlanDetails */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class PlanDetails { + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nullable private String description; + + public static final String SERIALIZED_NAME_FLAVOR_NAME = "flavorName"; + + @SerializedName(SERIALIZED_NAME_FLAVOR_NAME) + @javax.annotation.Nullable private String flavorName; + + public static final String SERIALIZED_NAME_MAX_CONNECTIONS = "maxConnections"; + + @SerializedName(SERIALIZED_NAME_MAX_CONNECTIONS) + @javax.annotation.Nullable private Integer maxConnections; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_PLAN_ID = "planId"; + + @SerializedName(SERIALIZED_NAME_PLAN_ID) + @javax.annotation.Nullable private String planId; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + public PlanDetails() {} + + public PlanDetails description(@javax.annotation.Nullable String description) { + this.description = description; + return this; + } + + /** + * Description + * + * @return description + */ + @javax.annotation.Nullable public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nullable String description) { + this.description = description; + } + + public PlanDetails flavorName(@javax.annotation.Nullable String flavorName) { + this.flavorName = flavorName; + return this; + } + + /** + * Flavor Name + * + * @return flavorName + */ + @javax.annotation.Nullable public String getFlavorName() { + return flavorName; + } + + public void setFlavorName(@javax.annotation.Nullable String flavorName) { + this.flavorName = flavorName; + } + + public PlanDetails maxConnections(@javax.annotation.Nullable Integer maxConnections) { + this.maxConnections = maxConnections; + return this; + } + + /** + * Maximum number of concurrent connections per load balancer VM instance. + * + * @return maxConnections + */ + @javax.annotation.Nullable public Integer getMaxConnections() { + return maxConnections; + } + + public void setMaxConnections(@javax.annotation.Nullable Integer maxConnections) { + this.maxConnections = maxConnections; + } + + public PlanDetails name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Service Plan Name + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public PlanDetails planId(@javax.annotation.Nullable String planId) { + this.planId = planId; + return this; + } + + /** + * Service Plan Identifier + * + * @return planId + */ + @javax.annotation.Nullable public String getPlanId() { + return planId; + } + + public void setPlanId(@javax.annotation.Nullable String planId) { + this.planId = planId; + } + + public PlanDetails region(@javax.annotation.Nullable String region) { + this.region = region; + return this; + } + + /** + * Region this Plan is available in + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + public void setRegion(@javax.annotation.Nullable String region) { + this.region = region; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlanDetails planDetails = (PlanDetails) o; + return Objects.equals(this.description, planDetails.description) + && Objects.equals(this.flavorName, planDetails.flavorName) + && Objects.equals(this.maxConnections, planDetails.maxConnections) + && Objects.equals(this.name, planDetails.name) + && Objects.equals(this.planId, planDetails.planId) + && Objects.equals(this.region, planDetails.region); + } + + @Override + public int hashCode() { + return Objects.hash(description, flavorName, maxConnections, name, planId, region); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PlanDetails {\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" flavorName: ").append(toIndentedString(flavorName)).append("\n"); + sb.append(" maxConnections: ").append(toIndentedString(maxConnections)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" planId: ").append(toIndentedString(planId)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "description", + "flavorName", + "maxConnections", + "name", + "planId", + "region")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to PlanDetails + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!PlanDetails.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in PlanDetails is not found in the empty JSON string", + PlanDetails.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!PlanDetails.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `PlanDetails` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) + && !jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `description` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("description").toString())); + } + if ((jsonObj.get("flavorName") != null && !jsonObj.get("flavorName").isJsonNull()) + && !jsonObj.get("flavorName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `flavorName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("flavorName").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if ((jsonObj.get("planId") != null && !jsonObj.get("planId").isJsonNull()) + && !jsonObj.get("planId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `planId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("planId").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PlanDetails.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PlanDetails' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(PlanDetails.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, PlanDetails value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PlanDetails read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of PlanDetails given an JSON string + * + * @param jsonString JSON string + * @return An instance of PlanDetails + * @throws IOException if the JSON string is invalid with respect to PlanDetails + */ + public static PlanDetails fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PlanDetails.class); + } + + /** + * Convert an instance of PlanDetails to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java new file mode 100644 index 0000000..a2f9ae8 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SecurityGroup.java @@ -0,0 +1,227 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** SecurityGroup */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class SecurityGroup { + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nullable private String id; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public SecurityGroup() {} + + public SecurityGroup id(@javax.annotation.Nullable String id) { + this.id = id; + return this; + } + + /** + * ID of the security Group + * + * @return id + */ + @javax.annotation.Nullable public String getId() { + return id; + } + + public void setId(@javax.annotation.Nullable String id) { + this.id = id; + } + + public SecurityGroup name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Name of the security Group + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SecurityGroup securityGroup = (SecurityGroup) o; + return Objects.equals(this.id, securityGroup.id) + && Objects.equals(this.name, securityGroup.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SecurityGroup {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("id", "name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SecurityGroup + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SecurityGroup.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in SecurityGroup is not found in the empty JSON string", + SecurityGroup.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SecurityGroup.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `SecurityGroup` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) + && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `id` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("id").toString())); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SecurityGroup.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SecurityGroup' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(SecurityGroup.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, SecurityGroup value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SecurityGroup read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of SecurityGroup given an JSON string + * + * @param jsonString JSON string + * @return An instance of SecurityGroup + * @throws IOException if the JSON string is invalid with respect to SecurityGroup + */ + public static SecurityGroup fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SecurityGroup.class); + } + + /** + * Convert an instance of SecurityGroup to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java new file mode 100644 index 0000000..3c8b927 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/ServerNameIndicator.java @@ -0,0 +1,196 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** ServerNameIndicator */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class ServerNameIndicator { + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public ServerNameIndicator() {} + + public ServerNameIndicator name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * The domain name for this SNI config. + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ServerNameIndicator serverNameIndicator = (ServerNameIndicator) o; + return Objects.equals(this.name, serverNameIndicator.name); + } + + @Override + public int hashCode() { + return Objects.hash(name); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ServerNameIndicator {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("name")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ServerNameIndicator + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ServerNameIndicator.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in ServerNameIndicator is not found in the empty JSON string", + ServerNameIndicator.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!ServerNameIndicator.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `ServerNameIndicator` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ServerNameIndicator.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ServerNameIndicator' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(ServerNameIndicator.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, ServerNameIndicator value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ServerNameIndicator read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of ServerNameIndicator given an JSON string + * + * @param jsonString JSON string + * @return An instance of ServerNameIndicator + * @throws IOException if the JSON string is invalid with respect to ServerNameIndicator + */ + public static ServerNameIndicator fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ServerNameIndicator.class); + } + + /** + * Convert an instance of ServerNameIndicator to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java new file mode 100644 index 0000000..be83008 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/SessionPersistence.java @@ -0,0 +1,193 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** SessionPersistence */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class SessionPersistence { + public static final String SERIALIZED_NAME_USE_SOURCE_IP_ADDRESS = "useSourceIpAddress"; + + @SerializedName(SERIALIZED_NAME_USE_SOURCE_IP_ADDRESS) + @javax.annotation.Nullable private Boolean useSourceIpAddress; + + public SessionPersistence() {} + + public SessionPersistence useSourceIpAddress( + @javax.annotation.Nullable Boolean useSourceIpAddress) { + this.useSourceIpAddress = useSourceIpAddress; + return this; + } + + /** + * If enabled then all connections from one source IP address are redirected to the same target. + * This setting changes the load balancing algorithm to Maglev. + * + * @return useSourceIpAddress + */ + @javax.annotation.Nullable public Boolean getUseSourceIpAddress() { + return useSourceIpAddress; + } + + public void setUseSourceIpAddress(@javax.annotation.Nullable Boolean useSourceIpAddress) { + this.useSourceIpAddress = useSourceIpAddress; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SessionPersistence sessionPersistence = (SessionPersistence) o; + return Objects.equals(this.useSourceIpAddress, sessionPersistence.useSourceIpAddress); + } + + @Override + public int hashCode() { + return Objects.hash(useSourceIpAddress); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SessionPersistence {\n"); + sb.append(" useSourceIpAddress: ") + .append(toIndentedString(useSourceIpAddress)) + .append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("useSourceIpAddress")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SessionPersistence + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SessionPersistence.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in SessionPersistence is not found in the empty JSON string", + SessionPersistence.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!SessionPersistence.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `SessionPersistence` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SessionPersistence.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SessionPersistence' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(SessionPersistence.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, SessionPersistence value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public SessionPersistence read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of SessionPersistence given an JSON string + * + * @param jsonString JSON string + * @return An instance of SessionPersistence + * @throws IOException if the JSON string is invalid with respect to SessionPersistence + */ + public static SessionPersistence fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SessionPersistence.class); + } + + /** + * Convert an instance of SessionPersistence to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java new file mode 100644 index 0000000..1a48e10 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Status.java @@ -0,0 +1,273 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * The `Status` type defines a logical error model that is suitable for different + * programming environments, including REST APIs and RPC APIs. It is used by + * [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: + * error code, error message, and error details. You can find out more about this error model and + * how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors). + */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Status { + public static final String SERIALIZED_NAME_CODE = "code"; + + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nullable private Integer code; + + public static final String SERIALIZED_NAME_DETAILS = "details"; + + @SerializedName(SERIALIZED_NAME_DETAILS) + @javax.annotation.Nullable private List details = new ArrayList<>(); + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + @javax.annotation.Nullable private String message; + + public Status() {} + + public Status code(@javax.annotation.Nullable Integer code) { + this.code = code; + return this; + } + + /** + * The status code, which should be an enum value of [google.rpc.Code][google.rpc.Code]. + * + * @return code + */ + @javax.annotation.Nullable public Integer getCode() { + return code; + } + + public void setCode(@javax.annotation.Nullable Integer code) { + this.code = code; + } + + public Status details(@javax.annotation.Nullable List details) { + this.details = details; + return this; + } + + public Status addDetailsItem(GoogleProtobufAny detailsItem) { + if (this.details == null) { + this.details = new ArrayList<>(); + } + this.details.add(detailsItem); + return this; + } + + /** + * A list of messages that carry the error details. There is a common set of message types for + * APIs to use. + * + * @return details + */ + @javax.annotation.Nullable public List getDetails() { + return details; + } + + public void setDetails(@javax.annotation.Nullable List details) { + this.details = details; + } + + public Status message(@javax.annotation.Nullable String message) { + this.message = message; + return this; + } + + /** + * A developer-facing error message, which should be in English. Any user-facing error message + * should be localized and sent in the [google.rpc.Status.details][google.rpc.Status.details] + * field, or localized by the client. + * + * @return message + */ + @javax.annotation.Nullable public String getMessage() { + return message; + } + + public void setMessage(@javax.annotation.Nullable String message) { + this.message = message; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Status status = (Status) o; + return Objects.equals(this.code, status.code) + && Objects.equals(this.details, status.details) + && Objects.equals(this.message, status.message); + } + + @Override + public int hashCode() { + return Objects.hash(code, details, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Status {\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" details: ").append(toIndentedString(details)).append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("code", "details", "message")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Status + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Status.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Status is not found in the empty JSON string", + Status.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Status.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `Status` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the optional json data is an array if present + if (jsonObj.get("details") != null + && !jsonObj.get("details").isJsonNull() + && !jsonObj.get("details").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `details` to be an array in the JSON string but got `%s`", + jsonObj.get("details").toString())); + } + if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) + && !jsonObj.get("message").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `message` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("message").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Status.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Status' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Status.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Status value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Status read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of Status given an JSON string + * + * @param jsonString JSON string + * @return An instance of Status + * @throws IOException if the JSON string is invalid with respect to Status + */ + public static Status fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Status.class); + } + + /** + * Convert an instance of Status to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java new file mode 100644 index 0000000..b4dfe74 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/Target.java @@ -0,0 +1,227 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** Target */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class Target { + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nullable private String displayName; + + public static final String SERIALIZED_NAME_IP = "ip"; + + @SerializedName(SERIALIZED_NAME_IP) + @javax.annotation.Nullable private String ip; + + public Target() {} + + public Target displayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Target name + * + * @return displayName + */ + @javax.annotation.Nullable public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + } + + public Target ip(@javax.annotation.Nullable String ip) { + this.ip = ip; + return this; + } + + /** + * Target IP. Must by unique within a target pool. + * + * @return ip + */ + @javax.annotation.Nullable public String getIp() { + return ip; + } + + public void setIp(@javax.annotation.Nullable String ip) { + this.ip = ip; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Target target = (Target) o; + return Objects.equals(this.displayName, target.displayName) + && Objects.equals(this.ip, target.ip); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, ip); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Target {\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" ip: ").append(toIndentedString(ip)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("displayName", "ip")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Target + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Target.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in Target is not found in the empty JSON string", + Target.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!Target.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `Target` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) + && !jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if ((jsonObj.get("ip") != null && !jsonObj.get("ip").isJsonNull()) + && !jsonObj.get("ip").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `ip` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("ip").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Target.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Target' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(Target.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, Target value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Target read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of Target given an JSON string + * + * @param jsonString JSON string + * @return An instance of Target + * @throws IOException if the JSON string is invalid with respect to Target + */ + public static Target fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Target.class); + } + + /** + * Convert an instance of Target to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java new file mode 100644 index 0000000..751f9f3 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/TargetPool.java @@ -0,0 +1,350 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** TargetPool */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class TargetPool { + public static final String SERIALIZED_NAME_ACTIVE_HEALTH_CHECK = "activeHealthCheck"; + + @SerializedName(SERIALIZED_NAME_ACTIVE_HEALTH_CHECK) + @javax.annotation.Nullable private ActiveHealthCheck activeHealthCheck; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_SESSION_PERSISTENCE = "sessionPersistence"; + + @SerializedName(SERIALIZED_NAME_SESSION_PERSISTENCE) + @javax.annotation.Nullable private SessionPersistence sessionPersistence; + + public static final String SERIALIZED_NAME_TARGET_PORT = "targetPort"; + + @SerializedName(SERIALIZED_NAME_TARGET_PORT) + @javax.annotation.Nullable private Integer targetPort; + + public static final String SERIALIZED_NAME_TARGETS = "targets"; + + @SerializedName(SERIALIZED_NAME_TARGETS) + @javax.annotation.Nullable private List targets = new ArrayList<>(); + + public TargetPool() {} + + public TargetPool activeHealthCheck( + @javax.annotation.Nullable ActiveHealthCheck activeHealthCheck) { + this.activeHealthCheck = activeHealthCheck; + return this; + } + + /** + * Get activeHealthCheck + * + * @return activeHealthCheck + */ + @javax.annotation.Nullable public ActiveHealthCheck getActiveHealthCheck() { + return activeHealthCheck; + } + + public void setActiveHealthCheck( + @javax.annotation.Nullable ActiveHealthCheck activeHealthCheck) { + this.activeHealthCheck = activeHealthCheck; + } + + public TargetPool name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Target pool name + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public TargetPool sessionPersistence( + @javax.annotation.Nullable SessionPersistence sessionPersistence) { + this.sessionPersistence = sessionPersistence; + return this; + } + + /** + * Get sessionPersistence + * + * @return sessionPersistence + */ + @javax.annotation.Nullable public SessionPersistence getSessionPersistence() { + return sessionPersistence; + } + + public void setSessionPersistence( + @javax.annotation.Nullable SessionPersistence sessionPersistence) { + this.sessionPersistence = sessionPersistence; + } + + public TargetPool targetPort(@javax.annotation.Nullable Integer targetPort) { + this.targetPort = targetPort; + return this; + } + + /** + * The number identifying the port where each target listens for traffic. minimum: 1 maximum: + * 65535 + * + * @return targetPort + */ + @javax.annotation.Nullable public Integer getTargetPort() { + return targetPort; + } + + public void setTargetPort(@javax.annotation.Nullable Integer targetPort) { + this.targetPort = targetPort; + } + + public TargetPool targets(@javax.annotation.Nullable List targets) { + this.targets = targets; + return this; + } + + public TargetPool addTargetsItem(Target targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * List of all targets which will be used in the pool. Limited to 250. + * + * @return targets + */ + @javax.annotation.Nullable public List getTargets() { + return targets; + } + + public void setTargets(@javax.annotation.Nullable List targets) { + this.targets = targets; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + TargetPool targetPool = (TargetPool) o; + return Objects.equals(this.activeHealthCheck, targetPool.activeHealthCheck) + && Objects.equals(this.name, targetPool.name) + && Objects.equals(this.sessionPersistence, targetPool.sessionPersistence) + && Objects.equals(this.targetPort, targetPool.targetPort) + && Objects.equals(this.targets, targetPool.targets); + } + + @Override + public int hashCode() { + return Objects.hash(activeHealthCheck, name, sessionPersistence, targetPort, targets); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class TargetPool {\n"); + sb.append(" activeHealthCheck: ") + .append(toIndentedString(activeHealthCheck)) + .append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" sessionPersistence: ") + .append(toIndentedString(sessionPersistence)) + .append("\n"); + sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "activeHealthCheck", + "name", + "sessionPersistence", + "targetPort", + "targets")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to TargetPool + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!TargetPool.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in TargetPool is not found in the empty JSON string", + TargetPool.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!TargetPool.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `TargetPool` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `activeHealthCheck` + if (jsonObj.get("activeHealthCheck") != null + && !jsonObj.get("activeHealthCheck").isJsonNull()) { + ActiveHealthCheck.validateJsonElement(jsonObj.get("activeHealthCheck")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + // validate the optional field `sessionPersistence` + if (jsonObj.get("sessionPersistence") != null + && !jsonObj.get("sessionPersistence").isJsonNull()) { + SessionPersistence.validateJsonElement(jsonObj.get("sessionPersistence")); + } + if (jsonObj.get("targets") != null && !jsonObj.get("targets").isJsonNull()) { + JsonArray jsonArraytargets = jsonObj.getAsJsonArray("targets"); + if (jsonArraytargets != null) { + // ensure the json data is an array + if (!jsonObj.get("targets").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targets` to be an array in the JSON string but got `%s`", + jsonObj.get("targets").toString())); + } + + // validate the optional field `targets` (array) + for (int i = 0; i < jsonArraytargets.size(); i++) { + Target.validateJsonElement(jsonArraytargets.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!TargetPool.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'TargetPool' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(TargetPool.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, TargetPool value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public TargetPool read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of TargetPool given an JSON string + * + * @param jsonString JSON string + * @return An instance of TargetPool + * @throws IOException if the JSON string is invalid with respect to TargetPool + */ + public static TargetPool fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, TargetPool.class); + } + + /** + * Convert an instance of TargetPool to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java new file mode 100644 index 0000000..343cde8 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsPayload.java @@ -0,0 +1,263 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** UpdateCredentialsPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateCredentialsPayload { + public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName"; + + @SerializedName(SERIALIZED_NAME_DISPLAY_NAME) + @javax.annotation.Nullable private String displayName; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + + @SerializedName(SERIALIZED_NAME_PASSWORD) + @javax.annotation.Nullable private String password; + + public static final String SERIALIZED_NAME_USERNAME = "username"; + + @SerializedName(SERIALIZED_NAME_USERNAME) + @javax.annotation.Nullable private String username; + + public UpdateCredentialsPayload() {} + + public UpdateCredentialsPayload displayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + return this; + } + + /** + * Credential name + * + * @return displayName + */ + @javax.annotation.Nullable public String getDisplayName() { + return displayName; + } + + public void setDisplayName(@javax.annotation.Nullable String displayName) { + this.displayName = displayName; + } + + public UpdateCredentialsPayload password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * A valid password used for an existing STACKIT Observability instance, which is used during + * basic auth. + * + * @return password + */ + @javax.annotation.Nullable public String getPassword() { + return password; + } + + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + public UpdateCredentialsPayload username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * A valid username used for an existing STACKIT Observability instance, which is used during + * basic auth. + * + * @return username + */ + @javax.annotation.Nullable public String getUsername() { + return username; + } + + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateCredentialsPayload updateCredentialsPayload = (UpdateCredentialsPayload) o; + return Objects.equals(this.displayName, updateCredentialsPayload.displayName) + && Objects.equals(this.password, updateCredentialsPayload.password) + && Objects.equals(this.username, updateCredentialsPayload.username); + } + + @Override + public int hashCode() { + return Objects.hash(displayName, password, username); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateCredentialsPayload {\n"); + sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("displayName", "password", "username")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateCredentialsPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateCredentialsPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateCredentialsPayload is not found in the empty JSON string", + UpdateCredentialsPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpdateCredentialsPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `UpdateCredentialsPayload` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) + && !jsonObj.get("displayName").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("displayName").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) + && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `password` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("password").toString())); + } + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) + && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `username` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("username").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateCredentialsPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateCredentialsPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateCredentialsPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateCredentialsPayload value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateCredentialsPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateCredentialsPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateCredentialsPayload + * @throws IOException if the JSON string is invalid with respect to UpdateCredentialsPayload + */ + public static UpdateCredentialsPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateCredentialsPayload.class); + } + + /** + * Convert an instance of UpdateCredentialsPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java new file mode 100644 index 0000000..5b5e688 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateCredentialsResponse.java @@ -0,0 +1,195 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** UpdateCredentialsResponse */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateCredentialsResponse { + public static final String SERIALIZED_NAME_CREDENTIAL = "credential"; + + @SerializedName(SERIALIZED_NAME_CREDENTIAL) + @javax.annotation.Nullable private CredentialsResponse credential; + + public UpdateCredentialsResponse() {} + + public UpdateCredentialsResponse credential( + @javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + return this; + } + + /** + * Get credential + * + * @return credential + */ + @javax.annotation.Nullable public CredentialsResponse getCredential() { + return credential; + } + + public void setCredential(@javax.annotation.Nullable CredentialsResponse credential) { + this.credential = credential; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateCredentialsResponse updateCredentialsResponse = (UpdateCredentialsResponse) o; + return Objects.equals(this.credential, updateCredentialsResponse.credential); + } + + @Override + public int hashCode() { + return Objects.hash(credential); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateCredentialsResponse {\n"); + sb.append(" credential: ").append(toIndentedString(credential)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("credential")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateCredentialsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateCredentialsResponse.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateCredentialsResponse is not found in the empty JSON string", + UpdateCredentialsResponse.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpdateCredentialsResponse.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `UpdateCredentialsResponse` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `credential` + if (jsonObj.get("credential") != null && !jsonObj.get("credential").isJsonNull()) { + CredentialsResponse.validateJsonElement(jsonObj.get("credential")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateCredentialsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateCredentialsResponse' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateCredentialsResponse.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateCredentialsResponse value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateCredentialsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateCredentialsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateCredentialsResponse + * @throws IOException if the JSON string is invalid with respect to UpdateCredentialsResponse + */ + public static UpdateCredentialsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateCredentialsResponse.class); + } + + /** + * Convert an instance of UpdateCredentialsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java new file mode 100644 index 0000000..406ec4e --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateLoadBalancerPayload.java @@ -0,0 +1,848 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** UpdateLoadBalancerPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateLoadBalancerPayload { + public static final String SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT = + "disableTargetSecurityGroupAssignment"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TARGET_SECURITY_GROUP_ASSIGNMENT) + @javax.annotation.Nullable private Boolean disableTargetSecurityGroupAssignment; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nullable private List errors = new ArrayList<>(); + + public static final String SERIALIZED_NAME_EXTERNAL_ADDRESS = "externalAddress"; + + @SerializedName(SERIALIZED_NAME_EXTERNAL_ADDRESS) + @javax.annotation.Nullable private String externalAddress; + + public static final String SERIALIZED_NAME_LABELS = "labels"; + + @SerializedName(SERIALIZED_NAME_LABELS) + @javax.annotation.Nullable private Map labels = new HashMap<>(); + + public static final String SERIALIZED_NAME_LISTENERS = "listeners"; + + @SerializedName(SERIALIZED_NAME_LISTENERS) + @javax.annotation.Nullable private List listeners = new ArrayList<>(); + + public static final String SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP = + "loadBalancerSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_LOAD_BALANCER_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup loadBalancerSecurityGroup; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_NETWORKS = "networks"; + + @SerializedName(SERIALIZED_NAME_NETWORKS) + @javax.annotation.Nullable private List networks = new ArrayList<>(); + + public static final String SERIALIZED_NAME_OPTIONS = "options"; + + @SerializedName(SERIALIZED_NAME_OPTIONS) + @javax.annotation.Nullable private LoadBalancerOptions options; + + public static final String SERIALIZED_NAME_PLAN_ID = "planId"; + + @SerializedName(SERIALIZED_NAME_PLAN_ID) + @javax.annotation.Nullable private String planId; + + public static final String SERIALIZED_NAME_PRIVATE_ADDRESS = "privateAddress"; + + @SerializedName(SERIALIZED_NAME_PRIVATE_ADDRESS) + @javax.annotation.Nullable private String privateAddress; + + public static final String SERIALIZED_NAME_REGION = "region"; + + @SerializedName(SERIALIZED_NAME_REGION) + @javax.annotation.Nullable private String region; + + /** Gets or Sets status */ + @JsonAdapter(StatusEnum.Adapter.class) + public enum StatusEnum { + STATUS_UNSPECIFIED("STATUS_UNSPECIFIED"), + + STATUS_PENDING("STATUS_PENDING"), + + STATUS_READY("STATUS_READY"), + + STATUS_ERROR("STATUS_ERROR"), + + STATUS_TERMINATING("STATUS_TERMINATING"), + + UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api"); + + private String value; + + StatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StatusEnum fromValue(String value) { + for (StatusEnum b : StatusEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + return UNKNOWN_DEFAULT_OPEN_API; + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) + throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + StatusEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_STATUS = "status"; + + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nullable private StatusEnum status; + + public static final String SERIALIZED_NAME_TARGET_POOLS = "targetPools"; + + @SerializedName(SERIALIZED_NAME_TARGET_POOLS) + @javax.annotation.Nullable private List targetPools = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TARGET_SECURITY_GROUP = "targetSecurityGroup"; + + @SerializedName(SERIALIZED_NAME_TARGET_SECURITY_GROUP) + @javax.annotation.Nullable private SecurityGroup targetSecurityGroup; + + public static final String SERIALIZED_NAME_VERSION = "version"; + + @SerializedName(SERIALIZED_NAME_VERSION) + @javax.annotation.Nullable private String version; + + public UpdateLoadBalancerPayload() {} + + public UpdateLoadBalancerPayload( + List errors, + SecurityGroup loadBalancerSecurityGroup, + String privateAddress, + String region, + StatusEnum status, + SecurityGroup targetSecurityGroup) { + this(); + this.errors = errors; + this.loadBalancerSecurityGroup = loadBalancerSecurityGroup; + this.privateAddress = privateAddress; + this.region = region; + this.status = status; + this.targetSecurityGroup = targetSecurityGroup; + } + + public UpdateLoadBalancerPayload disableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + return this; + } + + /** + * Disable target security group assignemt to allow targets outside of the given network. + * Connectivity to targets need to be ensured by the customer, including routing and Security + * Groups (targetSecurityGroup can be assigned). Not changeable after creation. + * + * @return disableTargetSecurityGroupAssignment + */ + @javax.annotation.Nullable public Boolean getDisableTargetSecurityGroupAssignment() { + return disableTargetSecurityGroupAssignment; + } + + public void setDisableTargetSecurityGroupAssignment( + @javax.annotation.Nullable Boolean disableTargetSecurityGroupAssignment) { + this.disableTargetSecurityGroupAssignment = disableTargetSecurityGroupAssignment; + } + + /** + * Reports all errors a load balancer has. + * + * @return errors + */ + @javax.annotation.Nullable public List getErrors() { + return errors; + } + + public UpdateLoadBalancerPayload externalAddress( + @javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + return this; + } + + /** + * External load balancer IP address where this load balancer is exposed. Not changeable after + * creation. + * + * @return externalAddress + */ + @javax.annotation.Nullable public String getExternalAddress() { + return externalAddress; + } + + public void setExternalAddress(@javax.annotation.Nullable String externalAddress) { + this.externalAddress = externalAddress; + } + + public UpdateLoadBalancerPayload labels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + return this; + } + + public UpdateLoadBalancerPayload putLabelsItem(String key, String labelsItem) { + if (this.labels == null) { + this.labels = new HashMap<>(); + } + this.labels.put(key, labelsItem); + return this; + } + + /** + * Labels represent user-defined metadata as key-value pairs. Label count should not exceed 64 + * per LB. **Key Formatting Rules:** Length: 1-63 characters. Characters: Must begin and end + * with [a-zA-Z0-9]. May contain dashes (-), underscores (_), dots (.), and alphanumerics in + * between. Keys starting with 'stackit-' are system-reserved; users MUST NOT manage + * them. **Value Formatting Rules:** Length: 0-63 characters (empty string explicitly allowed). + * Characters (for non-empty values): Must begin and end with [a-zA-Z0-9]. May contain dashes + * (-), underscores (_), dots (.), and alphanumerics in between. + * + * @return labels + */ + @javax.annotation.Nullable public Map getLabels() { + return labels; + } + + public void setLabels(@javax.annotation.Nullable Map labels) { + this.labels = labels; + } + + public UpdateLoadBalancerPayload listeners( + @javax.annotation.Nullable List listeners) { + this.listeners = listeners; + return this; + } + + public UpdateLoadBalancerPayload addListenersItem(Listener listenersItem) { + if (this.listeners == null) { + this.listeners = new ArrayList<>(); + } + this.listeners.add(listenersItem); + return this; + } + + /** + * There is a maximum listener count of 20. Port and protocol limitations: - UDP listeners + * cannot have the same port. - TCP-derived listeners cannot have the same port. A TCP-derived + * listener is any listener that listens on a TCP port. As of now those are: TCP, TCP_PROXY, and + * PROTOCOL_TLS_PASSTHROUGH. The only exception is, if all listeners for the same port are + * PROTOCOL_TLS_PASSTHROUGH. - PROTOCOL_TLS_PASSTHROUGH listeners cannot have the same port and + * at least one common domain name. - PROTOCOL_TLS_PASSTHROUGH listeners can have the same + * domain name and different ports though (e.g. ports 443 and 8443 for domain example.com). - + * PROTOCOL_TLS_PASSTHROUGH listeners without a domain name serve as a default listener and you + * can have only one default listener. + * + * @return listeners + */ + @javax.annotation.Nullable public List getListeners() { + return listeners; + } + + public void setListeners(@javax.annotation.Nullable List listeners) { + this.listeners = listeners; + } + + /** + * Security Group permitting network traffic from the LoadBalancer to the targets. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return loadBalancerSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getLoadBalancerSecurityGroup() { + return loadBalancerSecurityGroup; + } + + public UpdateLoadBalancerPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Load balancer name. Not changeable after creation. + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public UpdateLoadBalancerPayload networks(@javax.annotation.Nullable List networks) { + this.networks = networks; + return this; + } + + public UpdateLoadBalancerPayload addNetworksItem(Network networksItem) { + if (this.networks == null) { + this.networks = new ArrayList<>(); + } + this.networks.add(networksItem); + return this; + } + + /** + * List of networks that listeners and targets reside in. Currently limited to one. Not + * changeable after creation. + * + * @return networks + */ + @javax.annotation.Nullable public List getNetworks() { + return networks; + } + + public void setNetworks(@javax.annotation.Nullable List networks) { + this.networks = networks; + } + + public UpdateLoadBalancerPayload options( + @javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + return this; + } + + /** + * Get options + * + * @return options + */ + @javax.annotation.Nullable public LoadBalancerOptions getOptions() { + return options; + } + + public void setOptions(@javax.annotation.Nullable LoadBalancerOptions options) { + this.options = options; + } + + public UpdateLoadBalancerPayload planId(@javax.annotation.Nullable String planId) { + this.planId = planId; + return this; + } + + /** + * Service Plan configures the size of the Load Balancer. Currently supported plans are p10, + * p50, p250 and p750. This list can change in the future where plan ids will be removed and new + * plans by added. That is the reason this is not an enum. + * + * @return planId + */ + @javax.annotation.Nullable public String getPlanId() { + return planId; + } + + public void setPlanId(@javax.annotation.Nullable String planId) { + this.planId = planId; + } + + /** + * Transient private load balancer IP address that can change any time. + * + * @return privateAddress + */ + @javax.annotation.Nullable public String getPrivateAddress() { + return privateAddress; + } + + /** + * Region of the LoadBalancer + * + * @return region + */ + @javax.annotation.Nullable public String getRegion() { + return region; + } + + /** + * Get status + * + * @return status + */ + @javax.annotation.Nullable public StatusEnum getStatus() { + return status; + } + + public UpdateLoadBalancerPayload targetPools( + @javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + return this; + } + + public UpdateLoadBalancerPayload addTargetPoolsItem(TargetPool targetPoolsItem) { + if (this.targetPools == null) { + this.targetPools = new ArrayList<>(); + } + this.targetPools.add(targetPoolsItem); + return this; + } + + /** + * List of all target pools which will be used in the load balancer. Limited to 20. + * + * @return targetPools + */ + @javax.annotation.Nullable public List getTargetPools() { + return targetPools; + } + + public void setTargetPools(@javax.annotation.Nullable List targetPools) { + this.targetPools = targetPools; + } + + /** + * Security Group that allows the targets to receive traffic from the LoadBalancer. Useful when + * disableTargetSecurityGroupAssignment=true to manually assign target security groups to + * targets. + * + * @return targetSecurityGroup + */ + @javax.annotation.Nullable public SecurityGroup getTargetSecurityGroup() { + return targetSecurityGroup; + } + + public UpdateLoadBalancerPayload version(@javax.annotation.Nullable String version) { + this.version = version; + return this; + } + + /** + * Load balancer resource version. Must be empty or unset for creating load balancers, non-empty + * for updating load balancers. Semantics: While retrieving load balancers, this is the current + * version of this load balancer resource that changes during updates of the load balancers. On + * updates this field specified the load balancer version you calculated your update for instead + * of the future version to enable concurrency safe updates. Update calls will then report the + * new version in their result as you would see with a load balancer retrieval call later. There + * exist no total order of the version, so you can only compare it for equality, but not for + * less/greater than another version. Since the creation of load balancer is always intended to + * create the first version of it, there should be no existing version. That's why this + * field must by empty of not present in that case. + * + * @return version + */ + @javax.annotation.Nullable public String getVersion() { + return version; + } + + public void setVersion(@javax.annotation.Nullable String version) { + this.version = version; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateLoadBalancerPayload updateLoadBalancerPayload = (UpdateLoadBalancerPayload) o; + return Objects.equals( + this.disableTargetSecurityGroupAssignment, + updateLoadBalancerPayload.disableTargetSecurityGroupAssignment) + && Objects.equals(this.errors, updateLoadBalancerPayload.errors) + && Objects.equals(this.externalAddress, updateLoadBalancerPayload.externalAddress) + && Objects.equals(this.labels, updateLoadBalancerPayload.labels) + && Objects.equals(this.listeners, updateLoadBalancerPayload.listeners) + && Objects.equals( + this.loadBalancerSecurityGroup, + updateLoadBalancerPayload.loadBalancerSecurityGroup) + && Objects.equals(this.name, updateLoadBalancerPayload.name) + && Objects.equals(this.networks, updateLoadBalancerPayload.networks) + && Objects.equals(this.options, updateLoadBalancerPayload.options) + && Objects.equals(this.planId, updateLoadBalancerPayload.planId) + && Objects.equals(this.privateAddress, updateLoadBalancerPayload.privateAddress) + && Objects.equals(this.region, updateLoadBalancerPayload.region) + && Objects.equals(this.status, updateLoadBalancerPayload.status) + && Objects.equals(this.targetPools, updateLoadBalancerPayload.targetPools) + && Objects.equals( + this.targetSecurityGroup, updateLoadBalancerPayload.targetSecurityGroup) + && Objects.equals(this.version, updateLoadBalancerPayload.version); + } + + @Override + public int hashCode() { + return Objects.hash( + disableTargetSecurityGroupAssignment, + errors, + externalAddress, + labels, + listeners, + loadBalancerSecurityGroup, + name, + networks, + options, + planId, + privateAddress, + region, + status, + targetPools, + targetSecurityGroup, + version); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateLoadBalancerPayload {\n"); + sb.append(" disableTargetSecurityGroupAssignment: ") + .append(toIndentedString(disableTargetSecurityGroupAssignment)) + .append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" externalAddress: ").append(toIndentedString(externalAddress)).append("\n"); + sb.append(" labels: ").append(toIndentedString(labels)).append("\n"); + sb.append(" listeners: ").append(toIndentedString(listeners)).append("\n"); + sb.append(" loadBalancerSecurityGroup: ") + .append(toIndentedString(loadBalancerSecurityGroup)) + .append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" networks: ").append(toIndentedString(networks)).append("\n"); + sb.append(" options: ").append(toIndentedString(options)).append("\n"); + sb.append(" planId: ").append(toIndentedString(planId)).append("\n"); + sb.append(" privateAddress: ").append(toIndentedString(privateAddress)).append("\n"); + sb.append(" region: ").append(toIndentedString(region)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" targetPools: ").append(toIndentedString(targetPools)).append("\n"); + sb.append(" targetSecurityGroup: ") + .append(toIndentedString(targetSecurityGroup)) + .append("\n"); + sb.append(" version: ").append(toIndentedString(version)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "disableTargetSecurityGroupAssignment", + "errors", + "externalAddress", + "labels", + "listeners", + "loadBalancerSecurityGroup", + "name", + "networks", + "options", + "planId", + "privateAddress", + "region", + "status", + "targetPools", + "targetSecurityGroup", + "version")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateLoadBalancerPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateLoadBalancerPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateLoadBalancerPayload is not found in the empty JSON string", + UpdateLoadBalancerPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpdateLoadBalancerPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `UpdateLoadBalancerPayload` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("errors") != null && !jsonObj.get("errors").isJsonNull()) { + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + if (jsonArrayerrors != null) { + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `errors` to be an array in the JSON string but got `%s`", + jsonObj.get("errors").toString())); + } + + // validate the optional field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + LoadBalancerError.validateJsonElement(jsonArrayerrors.get(i)); + } + ; + } + } + if ((jsonObj.get("externalAddress") != null && !jsonObj.get("externalAddress").isJsonNull()) + && !jsonObj.get("externalAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `externalAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("externalAddress").toString())); + } + if (jsonObj.get("listeners") != null && !jsonObj.get("listeners").isJsonNull()) { + JsonArray jsonArraylisteners = jsonObj.getAsJsonArray("listeners"); + if (jsonArraylisteners != null) { + // ensure the json data is an array + if (!jsonObj.get("listeners").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `listeners` to be an array in the JSON string but got `%s`", + jsonObj.get("listeners").toString())); + } + + // validate the optional field `listeners` (array) + for (int i = 0; i < jsonArraylisteners.size(); i++) { + Listener.validateJsonElement(jsonArraylisteners.get(i)); + } + ; + } + } + // validate the optional field `loadBalancerSecurityGroup` + if (jsonObj.get("loadBalancerSecurityGroup") != null + && !jsonObj.get("loadBalancerSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("loadBalancerSecurityGroup")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + if (jsonObj.get("networks") != null && !jsonObj.get("networks").isJsonNull()) { + JsonArray jsonArraynetworks = jsonObj.getAsJsonArray("networks"); + if (jsonArraynetworks != null) { + // ensure the json data is an array + if (!jsonObj.get("networks").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `networks` to be an array in the JSON string but got `%s`", + jsonObj.get("networks").toString())); + } + + // validate the optional field `networks` (array) + for (int i = 0; i < jsonArraynetworks.size(); i++) { + Network.validateJsonElement(jsonArraynetworks.get(i)); + } + ; + } + } + // validate the optional field `options` + if (jsonObj.get("options") != null && !jsonObj.get("options").isJsonNull()) { + LoadBalancerOptions.validateJsonElement(jsonObj.get("options")); + } + if ((jsonObj.get("planId") != null && !jsonObj.get("planId").isJsonNull()) + && !jsonObj.get("planId").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `planId` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("planId").toString())); + } + if ((jsonObj.get("privateAddress") != null && !jsonObj.get("privateAddress").isJsonNull()) + && !jsonObj.get("privateAddress").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `privateAddress` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("privateAddress").toString())); + } + if ((jsonObj.get("region") != null && !jsonObj.get("region").isJsonNull()) + && !jsonObj.get("region").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `region` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("region").toString())); + } + if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) + && !jsonObj.get("status").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `status` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("status").toString())); + } + // validate the optional field `status` + if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { + StatusEnum.validateJsonElement(jsonObj.get("status")); + } + if (jsonObj.get("targetPools") != null && !jsonObj.get("targetPools").isJsonNull()) { + JsonArray jsonArraytargetPools = jsonObj.getAsJsonArray("targetPools"); + if (jsonArraytargetPools != null) { + // ensure the json data is an array + if (!jsonObj.get("targetPools").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targetPools` to be an array in the JSON string but got `%s`", + jsonObj.get("targetPools").toString())); + } + + // validate the optional field `targetPools` (array) + for (int i = 0; i < jsonArraytargetPools.size(); i++) { + TargetPool.validateJsonElement(jsonArraytargetPools.get(i)); + } + ; + } + } + // validate the optional field `targetSecurityGroup` + if (jsonObj.get("targetSecurityGroup") != null + && !jsonObj.get("targetSecurityGroup").isJsonNull()) { + SecurityGroup.validateJsonElement(jsonObj.get("targetSecurityGroup")); + } + if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) + && !jsonObj.get("version").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `version` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("version").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateLoadBalancerPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateLoadBalancerPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateLoadBalancerPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateLoadBalancerPayload value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateLoadBalancerPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateLoadBalancerPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateLoadBalancerPayload + * @throws IOException if the JSON string is invalid with respect to UpdateLoadBalancerPayload + */ + public static UpdateLoadBalancerPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateLoadBalancerPayload.class); + } + + /** + * Convert an instance of UpdateLoadBalancerPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java new file mode 100644 index 0000000..0645b14 --- /dev/null +++ b/services/loadbalancer/src/main/java/cloud/stackit/sdk/loadbalancer/model/UpdateTargetPoolPayload.java @@ -0,0 +1,353 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.model; + +import cloud.stackit.sdk.loadbalancer.JSON; +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.TypeAdapter; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.annotations.SerializedName; +import com.google.gson.reflect.TypeToken; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** UpdateTargetPoolPayload */ +@javax.annotation.Generated( + value = "org.openapitools.codegen.languages.JavaClientCodegen", + comments = "Generator version: 7.15.0") +public class UpdateTargetPoolPayload { + public static final String SERIALIZED_NAME_ACTIVE_HEALTH_CHECK = "activeHealthCheck"; + + @SerializedName(SERIALIZED_NAME_ACTIVE_HEALTH_CHECK) + @javax.annotation.Nullable private ActiveHealthCheck activeHealthCheck; + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + @javax.annotation.Nullable private String name; + + public static final String SERIALIZED_NAME_SESSION_PERSISTENCE = "sessionPersistence"; + + @SerializedName(SERIALIZED_NAME_SESSION_PERSISTENCE) + @javax.annotation.Nullable private SessionPersistence sessionPersistence; + + public static final String SERIALIZED_NAME_TARGET_PORT = "targetPort"; + + @SerializedName(SERIALIZED_NAME_TARGET_PORT) + @javax.annotation.Nullable private Integer targetPort; + + public static final String SERIALIZED_NAME_TARGETS = "targets"; + + @SerializedName(SERIALIZED_NAME_TARGETS) + @javax.annotation.Nullable private List targets = new ArrayList<>(); + + public UpdateTargetPoolPayload() {} + + public UpdateTargetPoolPayload activeHealthCheck( + @javax.annotation.Nullable ActiveHealthCheck activeHealthCheck) { + this.activeHealthCheck = activeHealthCheck; + return this; + } + + /** + * Get activeHealthCheck + * + * @return activeHealthCheck + */ + @javax.annotation.Nullable public ActiveHealthCheck getActiveHealthCheck() { + return activeHealthCheck; + } + + public void setActiveHealthCheck( + @javax.annotation.Nullable ActiveHealthCheck activeHealthCheck) { + this.activeHealthCheck = activeHealthCheck; + } + + public UpdateTargetPoolPayload name(@javax.annotation.Nullable String name) { + this.name = name; + return this; + } + + /** + * Target pool name + * + * @return name + */ + @javax.annotation.Nullable public String getName() { + return name; + } + + public void setName(@javax.annotation.Nullable String name) { + this.name = name; + } + + public UpdateTargetPoolPayload sessionPersistence( + @javax.annotation.Nullable SessionPersistence sessionPersistence) { + this.sessionPersistence = sessionPersistence; + return this; + } + + /** + * Get sessionPersistence + * + * @return sessionPersistence + */ + @javax.annotation.Nullable public SessionPersistence getSessionPersistence() { + return sessionPersistence; + } + + public void setSessionPersistence( + @javax.annotation.Nullable SessionPersistence sessionPersistence) { + this.sessionPersistence = sessionPersistence; + } + + public UpdateTargetPoolPayload targetPort(@javax.annotation.Nullable Integer targetPort) { + this.targetPort = targetPort; + return this; + } + + /** + * The number identifying the port where each target listens for traffic. minimum: 1 maximum: + * 65535 + * + * @return targetPort + */ + @javax.annotation.Nullable public Integer getTargetPort() { + return targetPort; + } + + public void setTargetPort(@javax.annotation.Nullable Integer targetPort) { + this.targetPort = targetPort; + } + + public UpdateTargetPoolPayload targets(@javax.annotation.Nullable List targets) { + this.targets = targets; + return this; + } + + public UpdateTargetPoolPayload addTargetsItem(Target targetsItem) { + if (this.targets == null) { + this.targets = new ArrayList<>(); + } + this.targets.add(targetsItem); + return this; + } + + /** + * List of all targets which will be used in the pool. Limited to 250. + * + * @return targets + */ + @javax.annotation.Nullable public List getTargets() { + return targets; + } + + public void setTargets(@javax.annotation.Nullable List targets) { + this.targets = targets; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + UpdateTargetPoolPayload updateTargetPoolPayload = (UpdateTargetPoolPayload) o; + return Objects.equals(this.activeHealthCheck, updateTargetPoolPayload.activeHealthCheck) + && Objects.equals(this.name, updateTargetPoolPayload.name) + && Objects.equals( + this.sessionPersistence, updateTargetPoolPayload.sessionPersistence) + && Objects.equals(this.targetPort, updateTargetPoolPayload.targetPort) + && Objects.equals(this.targets, updateTargetPoolPayload.targets); + } + + @Override + public int hashCode() { + return Objects.hash(activeHealthCheck, name, sessionPersistence, targetPort, targets); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class UpdateTargetPoolPayload {\n"); + sb.append(" activeHealthCheck: ") + .append(toIndentedString(activeHealthCheck)) + .append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" sessionPersistence: ") + .append(toIndentedString(sessionPersistence)) + .append("\n"); + sb.append(" targetPort: ").append(toIndentedString(targetPort)).append("\n"); + sb.append(" targets: ").append(toIndentedString(targets)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces (except the first + * line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = + new HashSet( + Arrays.asList( + "activeHealthCheck", + "name", + "sessionPersistence", + "targetPort", + "targets")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to UpdateTargetPoolPayload + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!UpdateTargetPoolPayload.openapiRequiredFields + .isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException( + String.format( + "The required field(s) %s in UpdateTargetPoolPayload is not found in the empty JSON string", + UpdateTargetPoolPayload.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonElement.getAsJsonObject().entrySet(); + // check to see if the JSON string contains additional fields + for (Map.Entry entry : entries) { + if (!UpdateTargetPoolPayload.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException( + String.format( + "The field `%s` in the JSON string is not defined in the `UpdateTargetPoolPayload` properties. JSON: %s", + entry.getKey(), jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the optional field `activeHealthCheck` + if (jsonObj.get("activeHealthCheck") != null + && !jsonObj.get("activeHealthCheck").isJsonNull()) { + ActiveHealthCheck.validateJsonElement(jsonObj.get("activeHealthCheck")); + } + if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) + && !jsonObj.get("name").isJsonPrimitive()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `name` to be a primitive type in the JSON string but got `%s`", + jsonObj.get("name").toString())); + } + // validate the optional field `sessionPersistence` + if (jsonObj.get("sessionPersistence") != null + && !jsonObj.get("sessionPersistence").isJsonNull()) { + SessionPersistence.validateJsonElement(jsonObj.get("sessionPersistence")); + } + if (jsonObj.get("targets") != null && !jsonObj.get("targets").isJsonNull()) { + JsonArray jsonArraytargets = jsonObj.getAsJsonArray("targets"); + if (jsonArraytargets != null) { + // ensure the json data is an array + if (!jsonObj.get("targets").isJsonArray()) { + throw new IllegalArgumentException( + String.format( + "Expected the field `targets` to be an array in the JSON string but got `%s`", + jsonObj.get("targets").toString())); + } + + // validate the optional field `targets` (array) + for (int i = 0; i < jsonArraytargets.size(); i++) { + Target.validateJsonElement(jsonArraytargets.get(i)); + } + ; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!UpdateTargetPoolPayload.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'UpdateTargetPoolPayload' and its + // subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter = + gson.getDelegateAdapter(this, TypeToken.get(UpdateTargetPoolPayload.class)); + + return (TypeAdapter) + new TypeAdapter() { + @Override + public void write(JsonWriter out, UpdateTargetPoolPayload value) + throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public UpdateTargetPoolPayload read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + return thisAdapter.fromJsonTree(jsonElement); + } + }.nullSafe(); + } + } + + /** + * Create an instance of UpdateTargetPoolPayload given an JSON string + * + * @param jsonString JSON string + * @return An instance of UpdateTargetPoolPayload + * @throws IOException if the JSON string is invalid with respect to UpdateTargetPoolPayload + */ + public static UpdateTargetPoolPayload fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, UpdateTargetPoolPayload.class); + } + + /** + * Convert an instance of UpdateTargetPoolPayload to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} diff --git a/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/DefaultApiTest.java b/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/DefaultApiTest.java new file mode 100644 index 0000000..b1b6cd8 --- /dev/null +++ b/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/DefaultApiTest.java @@ -0,0 +1,66 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.auth.SetupAuth; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.utils.TestUtils; +import java.io.IOException; +import okhttp3.Authenticator; +import okhttp3.OkHttpClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +public class DefaultApiTest { + @Test + public void TestCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + OkHttpClient httpClient = new OkHttpClient(); + ApiClient apiClient = new ApiClient(httpClient, conf); + + // then + Assertions.assertEquals(httpClient, apiClient.getHttpClient()); + // make sure the http client object is exactly the same object + Assertions.assertSame(httpClient, apiClient.getHttpClient()); + } + + @Test + public void TestNoCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + ApiClient apiClient = new ApiClient(conf); + + // then + /* + * verify a fresh OkHttpClient got created which will have the auth header set + * by the {@link cloud.stackit.sdk.core.KeyFlowAuthenticator} + */ + OkHttpClient httpClient = new OkHttpClient(); + Authenticator authenticator = + new KeyFlowAuthenticator(httpClient, conf, SetupAuth.setupKeyFlow(conf)); + httpClient = httpClient.newBuilder().authenticator(authenticator).build(); + + Assertions.assertNotNull(apiClient.getHttpClient()); + Assertions.assertEquals( + httpClient.authenticator().getClass(), + apiClient.getHttpClient().authenticator().getClass()); + } +} diff --git a/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApiTest.java b/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApiTest.java new file mode 100644 index 0000000..2bbb5bc --- /dev/null +++ b/services/loadbalancer/src/test/java/cloud/stackit/sdk/loadbalancer/api/LoadBalancerApiTest.java @@ -0,0 +1,67 @@ +/* + * STACKIT Load Balancer API + * This API offers an interface to provision and manage load balancing servers in your STACKIT project. It also has the possibility of pooling target servers for load balancing purposes. For each load balancer provided, two VMs are deployed in your OpenStack project subject to a fee. + * + * The version of the OpenAPI document: 2.0.0 + * + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package cloud.stackit.sdk.loadbalancer.api; + +import cloud.stackit.sdk.core.KeyFlowAuthenticator; +import cloud.stackit.sdk.core.auth.SetupAuth; +import cloud.stackit.sdk.core.config.CoreConfiguration; +import cloud.stackit.sdk.core.utils.TestUtils; +import java.io.IOException; +import okhttp3.Authenticator; +import okhttp3.OkHttpClient; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +/** API tests for LoadBalancerApi */ +public class LoadBalancerApiTest { + @Test + public void TestCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + OkHttpClient httpClient = new OkHttpClient(); + LoadBalancerApi api = new LoadBalancerApi(httpClient); + + // then + Assertions.assertEquals(httpClient, api.getApiClient().getHttpClient()); + // make sure the http client object is exactly the same object + Assertions.assertSame(httpClient, api.getApiClient().getHttpClient()); + } + + @Test + public void TestNoCustomHttpClient() throws IOException { + // before + CoreConfiguration conf = + new CoreConfiguration().serviceAccountKey(TestUtils.MOCK_SERVICE_ACCOUNT_KEY); + + // when + LoadBalancerApi api = new LoadBalancerApi(conf); + + // then + /* + * verify a fresh OkHttpClient got created which will have the auth header set + * by the {@link cloud.stackit.sdk.core.KeyFlowAuthenticator} + */ + OkHttpClient httpClient = new OkHttpClient(); + Authenticator authenticator = + new KeyFlowAuthenticator(httpClient, conf, SetupAuth.setupKeyFlow(conf)); + httpClient = httpClient.newBuilder().authenticator(authenticator).build(); + + Assertions.assertNotNull(api.getApiClient().getHttpClient()); + Assertions.assertEquals( + httpClient.authenticator().getClass(), + api.getApiClient().getHttpClient().authenticator().getClass()); + } +}