From 453636b244a3dd566a9834f93323caae53d3489c Mon Sep 17 00:00:00 2001 From: Piotr Kliczewski Date: Fri, 26 May 2023 17:55:26 +0200 Subject: [PATCH] Release 1.0.13 --- coverage/pom.xml | 2 +- notification-service-sdk/README.md | 6 +- .../notification/sdk/api/ApiCallback.java | 76 +- .../notification/sdk/api/ApiClient.java | 2977 ++++++++--------- .../notification/sdk/api/ApiException.java | 302 +- .../notification/sdk/api/ApiResponse.java | 108 +- .../notification/sdk/api/Configuration.java | 41 +- .../sdk/api/GzipRequestInterceptor.java | 103 +- .../parodos/notification/sdk/api/JSON.java | 574 ++-- .../sdk/api/NotificationMessageApi.java | 422 +-- .../sdk/api/NotificationRecordApi.java | 1694 ++++------ .../parodos/notification/sdk/api/Pair.java | 66 +- .../sdk/api/ProgressRequestBody.java | 98 +- .../sdk/api/ProgressResponseBody.java | 82 +- .../sdk/api/ServerConfiguration.java | 102 +- .../notification/sdk/api/ServerVariable.java | 31 +- .../notification/sdk/api/StringUtil.java | 121 +- .../notification/sdk/api/auth/ApiKeyAuth.java | 128 +- .../sdk/api/auth/Authentication.java | 37 +- .../sdk/api/auth/HttpBasicAuth.java | 74 +- .../sdk/api/auth/HttpBearerAuth.java | 90 +- .../sdk/model/AbstractOpenApiSchema.java | 243 +- .../sdk/model/ErrorMessageDTO.java | 471 +-- .../parodos/notification/sdk/model/Link.java | 782 +++-- .../NotificationMessageCreateRequestDTO.java | 631 ++-- .../model/NotificationRecordResponseDTO.java | 891 +++-- .../PageNotificationRecordResponseDTO.java | 872 ++--- .../sdk/model/PageableObject.java | 588 ++-- .../parodos/notification/sdk/model/Sort.java | 449 +-- notification-service/README.md | 2 +- notification-service/licenses/THIRD-PARTY.txt | 2 +- .../src/main/resources/application.yml | 2 +- pom.xml | 2 +- workflow-service-sdk/README.md | 6 +- .../redhat/parodos/sdk/invoker/ApiClient.java | 2 +- .../src/main/resources/application.yml | 2 +- 36 files changed, 5799 insertions(+), 6280 deletions(-) diff --git a/coverage/pom.xml b/coverage/pom.xml index 55a20b472..2a2eccbbd 100644 --- a/coverage/pom.xml +++ b/coverage/pom.xml @@ -12,7 +12,7 @@ Compute aggregated test code coverage true - 1.0.13-SNAPSHOT + 1.0.13 diff --git a/notification-service-sdk/README.md b/notification-service-sdk/README.md index 9aa458373..f8fd72916 100644 --- a/notification-service-sdk/README.md +++ b/notification-service-sdk/README.md @@ -39,7 +39,7 @@ Add this dependency to your project's POM: dev.parodos notification-service-sdk - 1.0.13-SNAPSHOT + 1.0.13 compile ``` @@ -55,7 +55,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "dev.parodos:notification-service-sdk:1.0.13-SNAPSHOT" + implementation "dev.parodos:notification-service-sdk:1.0.13" } ``` @@ -69,7 +69,7 @@ mvn clean package Then manually install the following JARs: -* `target/notification-service-sdk-1.0.13-SNAPSHOT.jar` +* `target/notification-service-sdk-1.0.13.jar` * `target/lib/*.jar` ## Getting Started diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiCallback.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiCallback.java index 6ed184dd0..a02b6f539 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiCallback.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiCallback.java @@ -3,17 +3,20 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.util.List; +import java.io.IOException; + import java.util.Map; +import java.util.List; /** * Callback for asynchronous API call. @@ -21,38 +24,39 @@ * @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); - + /** + * 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiClient.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiClient.java index bd5abf525..1c0dafcba 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiClient.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiClient.java @@ -3,15 +3,26 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.Buffer; +import okio.BufferedSink; +import okio.Okio; + +import javax.net.ssl.*; import java.io.File; import java.io.IOException; import java.io.InputStream; @@ -30,1513 +41,1485 @@ import java.security.cert.CertificateFactory; import java.security.cert.X509Certificate; import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.Map.Entry; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import javax.net.ssl.*; - -import com.redhat.parodos.notification.sdk.api.auth.ApiKeyAuth; import com.redhat.parodos.notification.sdk.api.auth.Authentication; import com.redhat.parodos.notification.sdk.api.auth.HttpBasicAuth; -import okhttp3.*; -import okhttp3.internal.http.HttpMethod; -import okhttp3.internal.tls.OkHostnameVerifier; -import okhttp3.logging.HttpLoggingInterceptor; -import okhttp3.logging.HttpLoggingInterceptor.Level; -import okio.Buffer; -import okio.BufferedSink; -import okio.Okio; +import com.redhat.parodos.notification.sdk.api.auth.HttpBearerAuth; +import com.redhat.parodos.notification.sdk.api.auth.ApiKeyAuth; /** - *

- * ApiClient class. - *

+ *

ApiClient class.

*/ public class ApiClient { - private String basePath = "http://localhost:8080"; - - protected List servers = new ArrayList( - Arrays.asList(new ServerConfiguration("http://localhost:8080", "Generated server url", - new HashMap()))); - - protected Integer serverIndex = 0; - - protected Map serverVariables = null; - - private boolean debugging = false; - - private Map defaultHeaderMap = new HashMap(); - - private Map defaultCookieMap = new HashMap(); - - private String tempFolderPath = null; - - private Map authentications; - - private DateFormat dateFormat; - - private DateFormat datetimeFormat; - - private boolean lenientDatetimeFormat; - - private int dateLength; - - private InputStream sslCaCert; - - private boolean verifyingSsl; - - private KeyManager[] keyManagers; - - private OkHttpClient httpClient; - - private JSON json; - - private HttpLoggingInterceptor loggingInterceptor; - - /** - * Basic constructor for ApiClient - */ - public ApiClient() { - init(); - initHttpClient(); - - // Setup authentications (key: authentication name, value: authentication). - // Prevent the authentications from being modified. - authentications = Collections.unmodifiableMap(authentications); - } - - /** - * Basic constructor with custom OkHttpClient - * @param client a {@link okhttp3.OkHttpClient} object - */ - public ApiClient(OkHttpClient client) { - init(); - - httpClient = client; - - // Setup authentications (key: authentication name, value: authentication). - // Prevent the authentications from being modified. - authentications = Collections.unmodifiableMap(authentications); - } - - private void initHttpClient() { - initHttpClient(Collections.emptyList()); - } - - private void initHttpClient(List interceptors) { - OkHttpClient.Builder builder = new OkHttpClient.Builder(); - builder.addNetworkInterceptor(getProgressInterceptor()); - for (Interceptor interceptor : interceptors) { - builder.addInterceptor(interceptor); - } - - httpClient = builder.build(); - } - - private void init() { - verifyingSsl = true; - - json = new JSON(); - - // Set default User-Agent. - setUserAgent("OpenAPI-Generator/1.0.13-SNAPSHOT/java"); - - authentications = new HashMap(); - } - - /** - * Get base path - * @return Base path - */ - public String getBasePath() { - return basePath; - } - - /** - * Set base path - * @param basePath Base path of the URL (e.g http://localhost:8080 - * @return An instance of OkHttpClient - */ - public ApiClient setBasePath(String basePath) { - this.basePath = basePath; - this.serverIndex = null; - return this; - } - - public List getServers() { - return servers; - } - - public ApiClient setServers(List servers) { - this.servers = servers; - return this; - } - - public Integer getServerIndex() { - return serverIndex; - } - - public ApiClient setServerIndex(Integer serverIndex) { - this.serverIndex = serverIndex; - return this; - } - - public Map getServerVariables() { - return serverVariables; - } - - public ApiClient setServerVariables(Map serverVariables) { - this.serverVariables = serverVariables; - return this; - } - - /** - * Get HTTP client - * @return An instance of OkHttpClient - */ - public OkHttpClient getHttpClient() { - return httpClient; - } - - /** - * Set HTTP client, which must never be null. - * @param newHttpClient An instance of OkHttpClient - * @return Api Client - * @throws java.lang.NullPointerException when newHttpClient is null - */ - public ApiClient setHttpClient(OkHttpClient newHttpClient) { - this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); - return this; - } - - /** - * Get JSON - * @return JSON object - */ - public JSON getJSON() { - return json; - } - - /** - * Set JSON - * @param json JSON object - * @return Api client - */ - public ApiClient setJSON(JSON json) { - this.json = json; - return this; - } - - /** - * True if isVerifyingSsl flag is on - * @return True if isVerifySsl flag is on - */ - public boolean isVerifyingSsl() { - return verifyingSsl; - } - - /** - * Configure whether to verify certificate and hostname when making https requests. - * Default to true. NOTE: Do NOT set to false in production code, otherwise you would - * face multiple types of cryptographic attacks. - * @param verifyingSsl True to verify TLS/SSL connection - * @return ApiClient - */ - public ApiClient setVerifyingSsl(boolean verifyingSsl) { - this.verifyingSsl = verifyingSsl; - applySslSettings(); - return this; - } - - /** - * Get SSL CA cert. - * @return Input stream to the SSL CA cert - */ - public InputStream getSslCaCert() { - return sslCaCert; - } - - /** - * Configure the CA certificate to be trusted when making https requests. Use null to - * reset to default. - * @param sslCaCert input stream for SSL CA cert - * @return ApiClient - */ - public ApiClient setSslCaCert(InputStream sslCaCert) { - this.sslCaCert = sslCaCert; - applySslSettings(); - return this; - } - - /** - *

- * Getter for the field keyManagers. - *

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

- * Getter for the field dateFormat. - *

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

- * Setter for the field dateFormat. - *

- * @param dateFormat a {@link java.text.DateFormat} object - * @return a {@link com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.ApiClient} object - */ - public ApiClient setSqlDateFormat(DateFormat dateFormat) { - JSON.setSqlDateFormat(dateFormat); - return this; - } - - /** - *

- * Set LenientOnJson. - *

- * @param lenientOnJson a boolean - * @return a {@link com.redhat.parodos.notification.sdk.api.ApiClient} object - */ - public ApiClient setLenientOnJson(boolean lenientOnJson) { - JSON.setLenientOnJson(lenientOnJson); - return this; - } - - /** - * Get authentications (key: authentication name, value: authentication). - * @return Map of authentication objects - */ - public Map getAuthentications() { - return authentications; - } - - /** - * Get authentication for the given name. - * @param authName The authentication name - * @return The authentication, null if not found - */ - public Authentication getAuthentication(String authName) { - return authentications.get(authName); - } - - /** - * Helper method to set username for the first HTTP basic authentication. - * @param username Username - */ - public void setUsername(String username) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setUsername(username); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set password for the first HTTP basic authentication. - * @param password Password - */ - public void setPassword(String password) { - for (Authentication auth : authentications.values()) { - if (auth instanceof HttpBasicAuth) { - ((HttpBasicAuth) auth).setPassword(password); - return; - } - } - throw new RuntimeException("No HTTP basic authentication configured!"); - } - - /** - * Helper method to set API key value for the first API key authentication. - * @param apiKey API key - */ - public void setApiKey(String apiKey) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKey(apiKey); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set API key prefix for the first API key authentication. - * @param apiKeyPrefix API key prefix - */ - public void setApiKeyPrefix(String apiKeyPrefix) { - for (Authentication auth : authentications.values()) { - if (auth instanceof ApiKeyAuth) { - ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); - return; - } - } - throw new RuntimeException("No API key authentication configured!"); - } - - /** - * Helper method to set access token for the first OAuth2 authentication. - * @param accessToken Access token - */ - public void setAccessToken(String accessToken) { - throw new RuntimeException("No OAuth2 authentication configured!"); - } - - /** - * Helper method to set credentials for AWSV4 Signature - * @param accessKey Access Key - * @param secretKey Secret Key - * @param region Region - * @param service Service to access to - */ - public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { - throw new RuntimeException("No AWS4 authentication configured!"); - } - - /** - * 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) { - // 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 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.replaceAll(".*[/\\\\]", ""); - } - - /** - * 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 com.redhat.parodos.notification.sdk.api.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); - } - - String respBody; - try { - if (response.body() != null) - respBody = response.body().string(); - else - respBody = null; - } - catch (IOException e) { - throw new ApiException(e); - } - - if (respBody == null || "".equals(respBody)) { - return null; - } - - String contentType = response.headers().get("Content-Type"); - if (contentType == null) { - // ensuring a default content type - contentType = "application/json"; - } - if (isJsonMime(contentType)) { - return JSON.deserialize(respBody, returnType); - } - else if (returnType.equals(String.class)) { - // Expecting string, return the raw response body. - return (T) respBody; - } - else { - throw new ApiException("Content type \"" + contentType + "\" is not supported for type: " + returnType, - response.code(), response.headers().toMultimap(), respBody); - } - } - - /** - * 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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 { - // aggregate queryParams (non-collection) and collectionQueryParams into - // allQueryParams - List allQueryParams = new ArrayList(queryParams); - allQueryParams.addAll(collectionQueryParams); - - final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); - - // prepare HTTP request body - RequestBody reqBody; - String contentType = headerParams.get("Content-Type"); - - if (!HttpMethod.permitsRequestBody(method)) { - reqBody = null; - } - else if ("application/x-www-form-urlencoded".equals(contentType)) { - reqBody = buildRequestBodyFormEncoding(formParams); - } - else if ("multipart/form-data".equals(contentType)) { - 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); - } - - // update parameters with authentication settings - updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, - URI.create(url)); - - final Request.Builder reqBuilder = new Request.Builder().url(url); - processHeaderParams(headerParams, reqBuilder); - processCookieParams(cookieParams, reqBuilder); - - // Associate callback with request (if not null) so interceptor can - // access it when creating ProgressResponseBody - reqBuilder.tag(callback); - - Request request = null; - - if (callback != null && reqBody != null) { - ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); - request = reqBuilder.method(method, progressRequestBody).build(); - } - else { - request = reqBuilder.method(method, reqBody).build(); - } - - return request; - } - - /** - * Build full URL by concatenating base path, the given sub path and query parameters. - * @param baseUrl The base URL - * @param path The sub path - * @param queryParams The query parameters - * @param collectionQueryParams The collection query parameters - * @return The full URL - */ - public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { - final StringBuilder url = new StringBuilder(); - if (baseUrl != null) { - url.append(baseUrl).append(path); - } - else { - String baseURL; - if (serverIndex != null) { - if (serverIndex < 0 || serverIndex >= servers.size()) { - throw new ArrayIndexOutOfBoundsException( - String.format("Invalid index %d when selecting the host settings. Must be less than %d", - serverIndex, servers.size())); - } - baseURL = servers.get(serverIndex).URL(serverVariables); - } - else { - baseURL = basePath; - } - url.append(baseURL).append(path); - } - - if (queryParams != null && !queryParams.isEmpty()) { - // support (constant) query string in `path`, e.g. "/posts?draft=1" - String prefix = path.contains("?") ? "&" : "?"; - for (Pair param : queryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } - else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - url.append(escapeString(param.getName())).append("=").append(escapeString(value)); - } - } - } - - if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { - String prefix = url.toString().contains("?") ? "&" : "?"; - for (Pair param : collectionQueryParams) { - if (param.getValue() != null) { - if (prefix != null) { - url.append(prefix); - prefix = null; - } - else { - url.append("&"); - } - String value = parameterToString(param.getValue()); - // collection query parameter value already escaped as part of - // parameterToPairs - url.append(escapeString(param.getName())).append("=").append(value); - } - } - } - - return url.toString(); - } - - /** - * Set header parameters to the request builder, including default headers. - * @param headerParams Header parameters in the form of Map - * @param reqBuilder Request.Builder - */ - public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { - for (Entry param : headerParams.entrySet()) { - reqBuilder.header(param.getKey(), parameterToString(param.getValue())); - } - for (Entry header : defaultHeaderMap.entrySet()) { - if (!headerParams.containsKey(header.getKey())) { - reqBuilder.header(header.getKey(), parameterToString(header.getValue())); - } - } - } - - /** - * Set cookie parameters to the request builder, including default cookies. - * @param cookieParams Cookie parameters in the form of Map - * @param reqBuilder Request.Builder - */ - public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { - for (Entry param : cookieParams.entrySet()) { - reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); - } - for (Entry param : defaultCookieMap.entrySet()) { - if (!cookieParams.containsKey(param.getKey())) { - reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); - } - } - } - - /** - * Update query and header parameters based on authentication settings. - * @param authNames The authentications to apply - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - * @param cookieParams Map of cookie parameters - * @param payload HTTP request body - * @param method HTTP method - * @param uri URI - * @throws com.redhat.parodos.notification.sdk.api.ApiException If fails to update the - * parameters - */ - public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, - Map cookieParams, String payload, String method, URI uri) throws ApiException { - for (String authName : authNames) { - Authentication auth = authentications.get(authName); - if (auth == null) { - throw new RuntimeException("Authentication undefined: " + authName); - } - auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); - } - } - - /** - * Build a form-encoding request body with the given form parameters. - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyFormEncoding(Map formParams) { - okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); - for (Entry param : formParams.entrySet()) { - formBuilder.add(param.getKey(), parameterToString(param.getValue())); - } - return formBuilder.build(); - } - - /** - * Build a multipart (file uploading) request body with the given form parameters, - * which could contain text fields and file fields. - * @param formParams Form parameters in the form of Map - * @return RequestBody - */ - public RequestBody buildRequestBodyMultipart(Map formParams) { - MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); - for (Entry param : formParams.entrySet()) { - if (param.getValue() instanceof File) { - File file = (File) param.getValue(); - addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); - } - else if (param.getValue() instanceof List) { - List list = (List) param.getValue(); - for (Object item : list) { - if (item instanceof File) { - addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); - } - else { - addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); - } - } - } - else { - addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); - } - } - return mpBuilder.build(); - } - - /** - * Guess Content-Type header from the given file (defaults to - * "application/octet-stream"). - * @param file The given file - * @return The guessed Content-Type - */ - public String guessContentTypeFromFile(File file) { - String contentType = URLConnection.guessContentTypeFromName(file.getName()); - if (contentType == null) { - return "application/octet-stream"; - } - else { - return contentType; - } - } - - /** - * Add a Content-Disposition Header for the given key and file to the MultipartBody - * Builder. - * @param mpBuilder MultipartBody.Builder - * @param key The key of the Header element - * @param file The file to add to the Header - */ - private 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 - */ - private 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. - */ - private 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. - */ - private 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); - } - } - - private 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 com.redhat.parodos.notification.sdk.api.ApiException If fail to serialize - * the request body object into a string - */ - private 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 ""; - } - + private String basePath = "http://localhost:8080"; + protected List servers = new ArrayList(Arrays.asList( + new ServerConfiguration( + "http://localhost:8080", + "Generated server url", + new HashMap() + ) + )); + protected Integer serverIndex = 0; + protected Map serverVariables = null; + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + private String tempFolderPath = null; + + private Map authentications; + + private DateFormat dateFormat; + private DateFormat datetimeFormat; + private boolean lenientDatetimeFormat; + private int dateLength; + + private InputStream sslCaCert; + private boolean verifyingSsl; + private KeyManager[] keyManagers; + + private OkHttpClient httpClient; + private JSON json; + + private HttpLoggingInterceptor loggingInterceptor; + + /** + * Basic constructor for ApiClient + */ + public ApiClient() { + init(); + initHttpClient(); + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + /** + * Basic constructor with custom OkHttpClient + * + * @param client a {@link okhttp3.OkHttpClient} object + */ + public ApiClient(OkHttpClient client) { + init(); + + httpClient = client; + + // Setup authentications (key: authentication name, value: authentication). + // Prevent the authentications from being modified. + authentications = Collections.unmodifiableMap(authentications); + } + + private void initHttpClient() { + initHttpClient(Collections.emptyList()); + } + + private void initHttpClient(List interceptors) { + OkHttpClient.Builder builder = new OkHttpClient.Builder(); + builder.addNetworkInterceptor(getProgressInterceptor()); + for (Interceptor interceptor: interceptors) { + builder.addInterceptor(interceptor); + } + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("OpenAPI-Generator/1.0.13/java"); + + authentications = new HashMap(); + } + + /** + * Get base path + * + * @return Base path + */ + public String getBasePath() { + return basePath; + } + + /** + * Set base path + * + * @param basePath Base path of the URL (e.g http://localhost:8080 + * @return An instance of OkHttpClient + */ + public ApiClient setBasePath(String basePath) { + this.basePath = basePath; + this.serverIndex = null; + return this; + } + + public List getServers() { + return servers; + } + + public ApiClient setServers(List servers) { + this.servers = servers; + return this; + } + + public Integer getServerIndex() { + return serverIndex; + } + + public ApiClient setServerIndex(Integer serverIndex) { + this.serverIndex = serverIndex; + return this; + } + + public Map getServerVariables() { + return serverVariables; + } + + public ApiClient setServerVariables(Map serverVariables) { + this.serverVariables = serverVariables; + return this; + } + + /** + * Get HTTP client + * + * @return An instance of OkHttpClient + */ + public OkHttpClient getHttpClient() { + return httpClient; + } + + /** + * Set HTTP client, which must never be null. + * + * @param newHttpClient An instance of OkHttpClient + * @return Api Client + * @throws java.lang.NullPointerException when newHttpClient is null + */ + public ApiClient setHttpClient(OkHttpClient newHttpClient) { + this.httpClient = Objects.requireNonNull(newHttpClient, "HttpClient must not be null!"); + return this; + } + + /** + * Get JSON + * + * @return JSON object + */ + public JSON getJSON() { + return json; + } + + /** + * Set JSON + * + * @param json JSON object + * @return Api client + */ + public ApiClient setJSON(JSON json) { + this.json = json; + return this; + } + + /** + * True if isVerifyingSsl flag is on + * + * @return True if isVerifySsl flag is on + */ + public boolean isVerifyingSsl() { + return verifyingSsl; + } + + /** + * Configure whether to verify certificate and hostname when making https requests. + * Default to true. + * NOTE: Do NOT set to false in production code, otherwise you would face multiple types of cryptographic attacks. + * + * @param verifyingSsl True to verify TLS/SSL connection + * @return ApiClient + */ + public ApiClient setVerifyingSsl(boolean verifyingSsl) { + this.verifyingSsl = verifyingSsl; + applySslSettings(); + return this; + } + + /** + * Get SSL CA cert. + * + * @return Input stream to the SSL CA cert + */ + public InputStream getSslCaCert() { + return sslCaCert; + } + + /** + * Configure the CA certificate to be trusted when making https requests. + * Use null to reset to default. + * + * @param sslCaCert input stream for SSL CA cert + * @return ApiClient + */ + public ApiClient setSslCaCert(InputStream sslCaCert) { + this.sslCaCert = sslCaCert; + applySslSettings(); + return this; + } + + /** + *

Getter for the field keyManagers.

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

Getter for the field dateFormat.

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

Setter for the field dateFormat.

+ * + * @param dateFormat a {@link java.text.DateFormat} object + * @return a {@link com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.ApiClient} object + */ + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + JSON.setSqlDateFormat(dateFormat); + return this; + } + + /** + *

Set LenientOnJson.

+ * + * @param lenientOnJson a boolean + * @return a {@link com.redhat.parodos.notification.sdk.api.ApiClient} object + */ + public ApiClient setLenientOnJson(boolean lenientOnJson) { + JSON.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Get authentications (key: authentication name, value: authentication). + * + * @return Map of authentication objects + */ + public Map getAuthentications() { + return authentications; + } + + /** + * Get authentication for the given name. + * + * @param authName The authentication name + * @return The authentication, null if not found + */ + public Authentication getAuthentication(String authName) { + return authentications.get(authName); + } + + + /** + * Helper method to set username for the first HTTP basic authentication. + * + * @param username Username + */ + public void setUsername(String username) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setUsername(username); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set password for the first HTTP basic authentication. + * + * @param password Password + */ + public void setPassword(String password) { + for (Authentication auth : authentications.values()) { + if (auth instanceof HttpBasicAuth) { + ((HttpBasicAuth) auth).setPassword(password); + return; + } + } + throw new RuntimeException("No HTTP basic authentication configured!"); + } + + /** + * Helper method to set API key value for the first API key authentication. + * + * @param apiKey API key + */ + public void setApiKey(String apiKey) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKey(apiKey); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set API key prefix for the first API key authentication. + * + * @param apiKeyPrefix API key prefix + */ + public void setApiKeyPrefix(String apiKeyPrefix) { + for (Authentication auth : authentications.values()) { + if (auth instanceof ApiKeyAuth) { + ((ApiKeyAuth) auth).setApiKeyPrefix(apiKeyPrefix); + return; + } + } + throw new RuntimeException("No API key authentication configured!"); + } + + /** + * Helper method to set access token for the first OAuth2 authentication. + * + * @param accessToken Access token + */ + public void setAccessToken(String accessToken) { + throw new RuntimeException("No OAuth2 authentication configured!"); + } + + /** + * Helper method to set credentials for AWSV4 Signature + * + * @param accessKey Access Key + * @param secretKey Secret Key + * @param region Region + * @param service Service to access to + */ + public void setAWS4Configuration(String accessKey, String secretKey, String region, String service) { + throw new RuntimeException("No AWS4 authentication configured!"); + } + + /** + * 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 ) { + //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 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.replaceAll(".*[/\\\\]", ""); + } + + /** + * 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 com.redhat.parodos.notification.sdk.api.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); + } + + String respBody; + try { + if (response.body() != null) + respBody = response.body().string(); + else + respBody = null; + } catch (IOException e) { + throw new ApiException(e); + } + + if (respBody == null || "".equals(respBody)) { + return null; + } + + String contentType = response.headers().get("Content-Type"); + if (contentType == null) { + // ensuring a default content type + contentType = "application/json"; + } + if (isJsonMime(contentType)) { + return JSON.deserialize(respBody, returnType); + } else if (returnType.equals(String.class)) { + // Expecting string, return the raw response body. + return (T) respBody; + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported for type: " + returnType, + response.code(), + response.headers().toMultimap(), + respBody); + } + } + + /** + * 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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 com.redhat.parodos.notification.sdk.api.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 { + // aggregate queryParams (non-collection) and collectionQueryParams into allQueryParams + List allQueryParams = new ArrayList(queryParams); + allQueryParams.addAll(collectionQueryParams); + + final String url = buildUrl(baseUrl, path, queryParams, collectionQueryParams); + + // prepare HTTP request body + RequestBody reqBody; + String contentType = headerParams.get("Content-Type"); + + if (!HttpMethod.permitsRequestBody(method)) { + reqBody = null; + } else if ("application/x-www-form-urlencoded".equals(contentType)) { + reqBody = buildRequestBodyFormEncoding(formParams); + } else if ("multipart/form-data".equals(contentType)) { + 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); + } + + // update parameters with authentication settings + updateParamsForAuth(authNames, allQueryParams, headerParams, cookieParams, requestBodyToString(reqBody), method, URI.create(url)); + + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + // Associate callback with request (if not null) so interceptor can + // access it when creating ProgressResponseBody + reqBuilder.tag(callback); + + Request request = null; + + if (callback != null && reqBody != null) { + ProgressRequestBody progressRequestBody = new ProgressRequestBody(reqBody, callback); + request = reqBuilder.method(method, progressRequestBody).build(); + } else { + request = reqBuilder.method(method, reqBody).build(); + } + + return request; + } + + /** + * Build full URL by concatenating base path, the given sub path and query parameters. + * + * @param baseUrl The base URL + * @param path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String baseUrl, String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + if (baseUrl != null) { + url.append(baseUrl).append(path); + } else { + String baseURL; + if (serverIndex != null) { + if (serverIndex < 0 || serverIndex >= servers.size()) { + throw new ArrayIndexOutOfBoundsException(String.format( + "Invalid index %d when selecting the host settings. Must be less than %d", serverIndex, servers.size() + )); + } + baseURL = servers.get(serverIndex).URL(serverVariables); + } else { + baseURL = basePath; + } + url.append(baseURL).append(path); + } + + if (queryParams != null && !queryParams.isEmpty()) { + // support (constant) query string in `path`, e.g. "/posts?draft=1" + String prefix = path.contains("?") ? "&" : "?"; + for (Pair param : queryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + url.append(escapeString(param.getName())).append("=").append(escapeString(value)); + } + } + } + + if (collectionQueryParams != null && !collectionQueryParams.isEmpty()) { + String prefix = url.toString().contains("?") ? "&" : "?"; + for (Pair param : collectionQueryParams) { + if (param.getValue() != null) { + if (prefix != null) { + url.append(prefix); + prefix = null; + } else { + url.append("&"); + } + String value = parameterToString(param.getValue()); + // collection query parameter value already escaped as part of parameterToPairs + url.append(escapeString(param.getName())).append("=").append(value); + } + } + } + + return url.toString(); + } + + /** + * Set header parameters to the request builder, including default headers. + * + * @param headerParams Header parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processHeaderParams(Map headerParams, Request.Builder reqBuilder) { + for (Entry param : headerParams.entrySet()) { + reqBuilder.header(param.getKey(), parameterToString(param.getValue())); + } + for (Entry header : defaultHeaderMap.entrySet()) { + if (!headerParams.containsKey(header.getKey())) { + reqBuilder.header(header.getKey(), parameterToString(header.getValue())); + } + } + } + + /** + * Set cookie parameters to the request builder, including default cookies. + * + * @param cookieParams Cookie parameters in the form of Map + * @param reqBuilder Request.Builder + */ + public void processCookieParams(Map cookieParams, Request.Builder reqBuilder) { + for (Entry param : cookieParams.entrySet()) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + for (Entry param : defaultCookieMap.entrySet()) { + if (!cookieParams.containsKey(param.getKey())) { + reqBuilder.addHeader("Cookie", String.format("%s=%s", param.getKey(), param.getValue())); + } + } + } + + /** + * Update query and header parameters based on authentication settings. + * + * @param authNames The authentications to apply + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws com.redhat.parodos.notification.sdk.api.ApiException If fails to update the parameters + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, + Map cookieParams, String payload, String method, URI uri) throws ApiException { + for (String authName : authNames) { + Authentication auth = authentications.get(authName); + if (auth == null) { + throw new RuntimeException("Authentication undefined: " + authName); + } + auth.applyToParams(queryParams, headerParams, cookieParams, payload, method, uri); + } + } + + /** + * Build a form-encoding request body with the given form parameters. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyFormEncoding(Map formParams) { + okhttp3.FormBody.Builder formBuilder = new okhttp3.FormBody.Builder(); + for (Entry param : formParams.entrySet()) { + formBuilder.add(param.getKey(), parameterToString(param.getValue())); + } + return formBuilder.build(); + } + + /** + * Build a multipart (file uploading) request body with the given form parameters, + * which could contain text fields and file fields. + * + * @param formParams Form parameters in the form of Map + * @return RequestBody + */ + public RequestBody buildRequestBodyMultipart(Map formParams) { + MultipartBody.Builder mpBuilder = new MultipartBody.Builder().setType(MultipartBody.FORM); + for (Entry param : formParams.entrySet()) { + if (param.getValue() instanceof File) { + File file = (File) param.getValue(); + addPartToMultiPartBuilder(mpBuilder, param.getKey(), file); + } else if (param.getValue() instanceof List) { + List list = (List) param.getValue(); + for (Object item: list) { + if (item instanceof File) { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), (File) item); + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + } else { + addPartToMultiPartBuilder(mpBuilder, param.getKey(), param.getValue()); + } + } + return mpBuilder.build(); + } + + /** + * Guess Content-Type header from the given file (defaults to "application/octet-stream"). + * + * @param file The given file + * @return The guessed Content-Type + */ + public String guessContentTypeFromFile(File file) { + String contentType = URLConnection.guessContentTypeFromName(file.getName()); + if (contentType == null) { + return "application/octet-stream"; + } else { + return contentType; + } + } + + /** + * Add a Content-Disposition Header for the given key and file to the MultipartBody Builder. + * + * @param mpBuilder MultipartBody.Builder + * @param key The key of the Header element + * @param file The file to add to the Header + */ + private 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 + */ + private 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. + */ + private 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. + */ + private 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); + } + } + + private 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 com.redhat.parodos.notification.sdk.api.ApiException If fail to serialize the request body object into a string + */ + private 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiException.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiException.java index 997b7661c..664faaf6d 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiException.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiException.java @@ -3,176 +3,164 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.util.List; import java.util.Map; +import java.util.List; + +import javax.ws.rs.core.GenericType; /** - *

- * ApiException class. - *

+ *

ApiException class.

*/ @SuppressWarnings("serial") @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiException extends Exception { - - private int code = 0; - - private Map> responseHeaders = null; - - private String responseBody = null; - - /** - *

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

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

- * Constructor for ApiException. - *

- * @param code HTTP status code - * @param message the error message - * @param responseHeaders a {@link java.util.Map} of HTTP response headers - * @param responseBody the response body - */ - public ApiException(int code, String message, Map> responseHeaders, String responseBody) { - this(code, message); - this.responseHeaders = responseHeaders; - this.responseBody = responseBody; - } - - /** - * Get the HTTP status code. - * @return HTTP status code - */ - public int getCode() { - return code; - } - - /** - * Get the HTTP response headers. - * @return A map of list of string - */ - public Map> getResponseHeaders() { - return responseHeaders; - } - - /** - * Get the HTTP response body. - * @return Response body in the form of string - */ - public String getResponseBody() { - return responseBody; - } - - /** - * Get the exception message including HTTP response data. - * @return The exception message - */ - public String getMessage() { - return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", - super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); - } - + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + /** + *

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

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

Constructor for ApiException.

+ * + * @param code HTTP status code + * @param message the error message + * @param responseHeaders a {@link java.util.Map} of HTTP response headers + * @param responseBody the response body + */ + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + /** + * Get the HTTP status code. + * + * @return HTTP status code + */ + public int getCode() { + return code; + } + + /** + * Get the HTTP response headers. + * + * @return A map of list of string + */ + public Map> getResponseHeaders() { + return responseHeaders; + } + + /** + * Get the HTTP response body. + * + * @return Response body in the form of string + */ + public String getResponseBody() { + return responseBody; + } + + /** + * Get the exception message including HTTP response data. + * + * @return The exception message + */ + public String getMessage() { + return String.format("Message: %s%nHTTP response code: %s%nHTTP response body: %s%nHTTP response headers: %s", + super.getMessage(), this.getCode(), this.getResponseBody(), this.getResponseHeaders()); + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiResponse.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiResponse.java index 5198aac6f..7e1d00ede 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiResponse.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ApiResponse.java @@ -3,13 +3,14 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; import java.util.List; @@ -19,66 +20,57 @@ * API response returned by API call. */ public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; - final private int statusCode; - - final private Map> headers; - - final private T data; - - /** - *

- * Constructor for ApiResponse. - *

- * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - */ - public ApiResponse(int statusCode, Map> headers) { - this(statusCode, headers, null); - } - - /** - *

- * Constructor for ApiResponse. - *

- * @param statusCode The status code of HTTP response - * @param headers The headers of HTTP response - * @param data The object deserialized from response bod - */ - public ApiResponse(int statusCode, Map> headers, T data) { - this.statusCode = statusCode; - this.headers = headers; - this.data = data; - } + /** + *

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); + } - /** - *

- * Get the status code. - *

- * @return the status code - */ - public int getStatusCode() { - return statusCode; - } + /** + *

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 headers. - *

- * @return a {@link java.util.Map} of headers - */ - public Map> getHeaders() { - return headers; - } + /** + *

Get the status code.

+ * + * @return the status code + */ + public int getStatusCode() { + return statusCode; + } - /** - *

- * Get the data. - *

- * @return the data - */ - public T getData() { - return data; - } + /** + *

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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Configuration.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Configuration.java index 0cd7fe1f7..c02812dce 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Configuration.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Configuration.java @@ -3,36 +3,37 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Configuration { + private static ApiClient defaultApiClient = new ApiClient(); - private static ApiClient defaultApiClient = new ApiClient(); - - /** - * Get the default API client, which would be used when creating API instances without - * providing an API client. - * @return Default API client - */ - public static ApiClient getDefaultApiClient() { - return defaultApiClient; - } - - /** - * Set the default API client, which would be used when creating API instances without - * providing an API client. - * @param apiClient API client - */ - public static void setDefaultApiClient(ApiClient apiClient) { - defaultApiClient = apiClient; - } + /** + * Get the default API client, which would be used when creating API + * instances without providing an API client. + * + * @return Default API client + */ + public static ApiClient getDefaultApiClient() { + return defaultApiClient; + } + /** + * Set the default API client, which would be used when creating API + * instances without providing an API client. + * + * @param apiClient API client + */ + public static void setDefaultApiClient(ApiClient apiClient) { + defaultApiClient = apiClient; + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/GzipRequestInterceptor.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/GzipRequestInterceptor.java index d4e689455..83ca783dc 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/GzipRequestInterceptor.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/GzipRequestInterceptor.java @@ -3,16 +3,15 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.io.IOException; +package com.redhat.parodos.notification.sdk.api; import okhttp3.*; import okio.Buffer; @@ -20,65 +19,67 @@ import okio.GzipSink; import okio.Okio; +import java.io.IOException; + /** * Encodes request bodies using gzip. * * Taken from https://github.com/square/okhttp/issues/350 */ class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } - @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(); - } + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } - @Override - public long contentLength() { - return buffer.size(); - } + 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 void writeTo(BufferedSink sink) throws IOException { - sink.write(buffer.snapshot()); - } - }; - } + @Override + public long contentLength() { + return buffer.size(); + } - private RequestBody gzip(final RequestBody body) { - return new RequestBody() { - @Override - public MediaType contentType() { - return body.contentType(); - } + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } - @Override - public long contentLength() { - return -1; // We don't know the compressed length in advance! - } + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } - @Override - public void writeTo(BufferedSink sink) throws IOException { - BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); - body.writeTo(gzipSink); - gzipSink.close(); - } - }; - } + @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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/JSON.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/JSON.java index 504a9d3d9..17113c197 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/JSON.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/JSON.java @@ -3,35 +3,43 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.io.IOException; -import java.io.StringReader; -import java.lang.reflect.Type; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.ParsePosition; -import java.util.Date; -import java.util.Map; +package com.redhat.parodos.notification.sdk.api; 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 com.google.gson.JsonElement; import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; + import okio.ByteString; +import java.io.IOException; +import java.io.StringReader; +import java.lang.reflect.Type; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.ParsePosition; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + /* * A JSON utility class * @@ -39,288 +47,264 @@ * 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 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; - } - - { - GsonBuilder gsonBuilder = createGson(); - gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); - gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); - gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.ErrorMessageDTO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.Link.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.NotificationMessageCreateRequestDTO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.NotificationRecordResponseDTO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.PageNotificationRecordResponseDTO.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.PageableObject.CustomTypeAdapterFactory()); - gsonBuilder.registerTypeAdapterFactory( - new com.redhat.parodos.notification.sdk.model.Sort.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); - } - } - } - - /** - * 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 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); - } - + private static Gson gson; + private static boolean isLenientOnJson = false; + private static DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private static SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + 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; + } + + { + GsonBuilder gsonBuilder = createGson(); + gsonBuilder.registerTypeAdapter(Date.class, dateTypeAdapter); + gsonBuilder.registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter); + gsonBuilder.registerTypeAdapter(byte[].class, byteArrayAdapter); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.ErrorMessageDTO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.Link.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.NotificationMessageCreateRequestDTO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.NotificationRecordResponseDTO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.PageNotificationRecordResponseDTO.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.PageableObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.redhat.parodos.notification.sdk.model.Sort.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); + } + } + } + + /** + * 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 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationMessageApi.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationMessageApi.java index 7556dedb3..48012c203 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationMessageApi.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationMessageApi.java @@ -3,256 +3,202 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; +import com.redhat.parodos.notification.sdk.api.ApiCallback; +import com.redhat.parodos.notification.sdk.api.ApiClient; +import com.redhat.parodos.notification.sdk.api.ApiException; +import com.redhat.parodos.notification.sdk.api.ApiResponse; +import com.redhat.parodos.notification.sdk.api.Configuration; +import com.redhat.parodos.notification.sdk.api.Pair; +import com.redhat.parodos.notification.sdk.api.ProgressRequestBody; +import com.redhat.parodos.notification.sdk.api.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.redhat.parodos.notification.sdk.model.ErrorMessageDTO; +import com.redhat.parodos.notification.sdk.model.NotificationMessageCreateRequestDTO; + +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; - -import com.redhat.parodos.notification.sdk.model.NotificationMessageCreateRequestDTO; +import javax.ws.rs.core.GenericType; public class NotificationMessageApi { - - private ApiClient localVarApiClient; - - private int localHostIndex; - - private String localCustomBaseUrl; - - public NotificationMessageApi() { - this(Configuration.getDefaultApiClient()); - } - - public NotificationMessageApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for create - * @param notificationMessageCreateRequestDTO (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
201Created-
400Bad Request-
404Not Found-
- */ - public okhttp3.Call createCall(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, - 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 = notificationMessageCreateRequestDTO; - - // create path and map variables - String localVarPath = "/api/v1/messages"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { "*/*" }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = { "application/json" }; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] {}; - return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, - localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, - localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call createValidateBeforeCall( - NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, final ApiCallback _callback) - throws ApiException { - // verify the required parameter 'notificationMessageCreateRequestDTO' is set - if (notificationMessageCreateRequestDTO == null) { - throw new ApiException( - "Missing the required parameter 'notificationMessageCreateRequestDTO' when calling create(Async)"); - } - - return createCall(notificationMessageCreateRequestDTO, _callback); - - } - - /** - * @param notificationMessageCreateRequestDTO (required) - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
201Created-
400Bad Request-
404Not Found-
- */ - public void create(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO) throws ApiException { - createWithHttpInfo(notificationMessageCreateRequestDTO); - } - - /** - * @param notificationMessageCreateRequestDTO (required) - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
201Created-
400Bad Request-
404Not Found-
- */ - public ApiResponse createWithHttpInfo(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO) - throws ApiException { - okhttp3.Call localVarCall = createValidateBeforeCall(notificationMessageCreateRequestDTO, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * (asynchronously) - * @param notificationMessageCreateRequestDTO (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
201Created-
400Bad Request-
404Not Found-
- */ - public okhttp3.Call createAsync(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, - final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = createValidateBeforeCall(notificationMessageCreateRequestDTO, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } - + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public NotificationMessageApi() { + this(Configuration.getDefaultApiClient()); + } + + public NotificationMessageApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for create + * @param notificationMessageCreateRequestDTO (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 + + + + + +
Status Code Description Response Headers
201 Created -
400 Bad Request -
404 Not Found -
+ */ + public okhttp3.Call createCall(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, 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 = notificationMessageCreateRequestDTO; + + // create path and map variables + String localVarPath = "/api/v1/messages"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "*/*" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createValidateBeforeCall(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'notificationMessageCreateRequestDTO' is set + if (notificationMessageCreateRequestDTO == null) { + throw new ApiException("Missing the required parameter 'notificationMessageCreateRequestDTO' when calling create(Async)"); + } + + return createCall(notificationMessageCreateRequestDTO, _callback); + + } + + /** + * + * + * @param notificationMessageCreateRequestDTO (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created -
400 Bad Request -
404 Not Found -
+ */ + public void create(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO) throws ApiException { + createWithHttpInfo(notificationMessageCreateRequestDTO); + } + + /** + * + * + * @param notificationMessageCreateRequestDTO (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + +
Status Code Description Response Headers
201 Created -
400 Bad Request -
404 Not Found -
+ */ + public ApiResponse createWithHttpInfo(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO) throws ApiException { + okhttp3.Call localVarCall = createValidateBeforeCall(notificationMessageCreateRequestDTO, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * (asynchronously) + * + * @param notificationMessageCreateRequestDTO (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 + + + + + +
Status Code Description Response Headers
201 Created -
400 Bad Request -
404 Not Found -
+ */ + public okhttp3.Call createAsync(NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createValidateBeforeCall(notificationMessageCreateRequestDTO, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationRecordApi.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationRecordApi.java index dc308f0df..0a7c19096 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationRecordApi.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/NotificationRecordApi.java @@ -3,1061 +3,671 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; +import com.redhat.parodos.notification.sdk.api.ApiCallback; +import com.redhat.parodos.notification.sdk.api.ApiClient; +import com.redhat.parodos.notification.sdk.api.ApiException; +import com.redhat.parodos.notification.sdk.api.ApiResponse; +import com.redhat.parodos.notification.sdk.api.Configuration; +import com.redhat.parodos.notification.sdk.api.Pair; +import com.redhat.parodos.notification.sdk.api.ProgressRequestBody; +import com.redhat.parodos.notification.sdk.api.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.redhat.parodos.notification.sdk.model.ErrorMessageDTO; +import com.redhat.parodos.notification.sdk.model.NotificationRecordResponseDTO; +import com.redhat.parodos.notification.sdk.model.PageNotificationRecordResponseDTO; +import java.util.UUID; + 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 com.google.gson.reflect.TypeToken; -import com.redhat.parodos.notification.sdk.model.NotificationRecordResponseDTO; -import com.redhat.parodos.notification.sdk.model.PageNotificationRecordResponseDTO; +import javax.ws.rs.core.GenericType; public class NotificationRecordApi { - - private ApiClient localVarApiClient; - - private int localHostIndex; - - private String localCustomBaseUrl; - - public NotificationRecordApi() { - this(Configuration.getDefaultApiClient()); - } - - public NotificationRecordApi(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public ApiClient getApiClient() { - return localVarApiClient; - } - - public void setApiClient(ApiClient apiClient) { - this.localVarApiClient = apiClient; - } - - public int getHostIndex() { - return localHostIndex; - } - - public void setHostIndex(int hostIndex) { - this.localHostIndex = hostIndex; - } - - public String getCustomBaseUrl() { - return localCustomBaseUrl; - } - - public void setCustomBaseUrl(String customBaseUrl) { - this.localCustomBaseUrl = customBaseUrl; - } - - /** - * Build call for countUnreadNotifications - * @param state (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call countUnreadNotificationsCall(String state, 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 = "/api/v1/notifications/count"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - if (state != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("state", state)); - } - - final String[] localVarAccepts = { "*/*" }; - 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 countUnreadNotificationsValidateBeforeCall(String state, final ApiCallback _callback) - throws ApiException { - // verify the required parameter 'state' is set - if (state == null) { - throw new ApiException( - "Missing the required parameter 'state' when calling countUnreadNotifications(Async)"); - } - - return countUnreadNotificationsCall(state, _callback); - - } - - /** - * Return the number of the unread notification records for the user - * @param state (required) - * @return Integer - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public Integer countUnreadNotifications(String state) throws ApiException { - ApiResponse localVarResp = countUnreadNotificationsWithHttpInfo(state); - return localVarResp.getData(); - } - - /** - * Return the number of the unread notification records for the user - * @param state (required) - * @return ApiResponse<Integer> - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public ApiResponse countUnreadNotificationsWithHttpInfo(String state) throws ApiException { - okhttp3.Call localVarCall = countUnreadNotificationsValidateBeforeCall(state, null); - Type localVarReturnType = new TypeToken() { - }.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Return the number of the unread notification records for the user (asynchronously) - * @param state (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call countUnreadNotificationsAsync(String state, final ApiCallback _callback) - throws ApiException { - - okhttp3.Call localVarCall = countUnreadNotificationsValidateBeforeCall(state, _callback); - Type localVarReturnType = new TypeToken() { - }.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - - /** - * Build call for deleteNotification - * @param id (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call deleteNotificationCall(UUID id, final ApiCallback _callback) throws ApiException { - String basePath = null; - // Operation Servers - String[] localBasePaths = new String[] {}; - - // Determine Base Path to Use - if (localCustomBaseUrl != null) { - basePath = localCustomBaseUrl; - } - else if (localBasePaths.length > 0) { - basePath = localBasePaths[localHostIndex]; - } - else { - basePath = null; - } - - Object localVarPostBody = null; - - // create path and map variables - String localVarPath = "/api/v1/notifications/{id}".replace("{" + "id" + "}", - localVarApiClient.escapeString(id.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - final String[] localVarAccepts = { "*/*" }; - 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 deleteNotificationValidateBeforeCall(UUID id, final ApiCallback _callback) - throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException("Missing the required parameter 'id' when calling deleteNotification(Async)"); - } - - return deleteNotificationCall(id, _callback); - - } - - /** - * Delete the specified notification record - * @param id (required) - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public void deleteNotification(UUID id) throws ApiException { - deleteNotificationWithHttpInfo(id); - } - - /** - * Delete the specified notification record - * @param id (required) - * @return ApiResponse<Void> - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public ApiResponse deleteNotificationWithHttpInfo(UUID id) throws ApiException { - okhttp3.Call localVarCall = deleteNotificationValidateBeforeCall(id, null); - return localVarApiClient.execute(localVarCall); - } - - /** - * Delete the specified notification record (asynchronously) - * @param id (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved the amount of notifications-
400Bad Request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call deleteNotificationAsync(UUID id, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = deleteNotificationValidateBeforeCall(id, _callback); - localVarApiClient.executeAsync(localVarCall, _callback); - return localVarCall; - } - - /** - * Build call for getNotifications - * @param page Zero-based page index (0..N) (optional, default to 0) - * @param size The size of the page to be returned (optional, default to 100) - * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order - * is ascending. Multiple sort criteria are supported. (optional) - * @param state (optional) - * @param searchTerm (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved page of notifications-
400Bad request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call getNotificationsCall(Integer page, Integer size, List sort, String state, - String searchTerm, 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 = "/api/v1/notifications"; - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - if (page != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("page", page)); - } - - if (size != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("size", size)); - } - - if (sort != null) { - localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "sort", sort)); - } - - if (state != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("state", state)); - } - - if (searchTerm != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("searchTerm", searchTerm)); - } - - final String[] localVarAccepts = { "*/*" }; - 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 getNotificationsValidateBeforeCall(Integer page, Integer size, List sort, String state, - String searchTerm, final ApiCallback _callback) throws ApiException { - return getNotificationsCall(page, size, sort, state, searchTerm, _callback); - - } - - /** - * Return a list of notification records for the user - * @param page Zero-based page index (0..N) (optional, default to 0) - * @param size The size of the page to be returned (optional, default to 100) - * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order - * is ascending. Multiple sort criteria are supported. (optional) - * @param state (optional) - * @param searchTerm (optional) - * @return PageNotificationRecordResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved page of notifications-
400Bad request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public PageNotificationRecordResponseDTO getNotifications(Integer page, Integer size, List sort, - String state, String searchTerm) throws ApiException { - ApiResponse localVarResp = getNotificationsWithHttpInfo(page, size, sort, - state, searchTerm); - return localVarResp.getData(); - } - - /** - * Return a list of notification records for the user - * @param page Zero-based page index (0..N) (optional, default to 0) - * @param size The size of the page to be returned (optional, default to 100) - * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order - * is ascending. Multiple sort criteria are supported. (optional) - * @param state (optional) - * @param searchTerm (optional) - * @return ApiResponse<PageNotificationRecordResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved page of notifications-
400Bad request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public ApiResponse getNotificationsWithHttpInfo(Integer page, Integer size, - List sort, String state, String searchTerm) throws ApiException { - okhttp3.Call localVarCall = getNotificationsValidateBeforeCall(page, size, sort, state, searchTerm, null); - Type localVarReturnType = new TypeToken() { - }.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Return a list of notification records for the user (asynchronously) - * @param page Zero-based page index (0..N) (optional, default to 0) - * @param size The size of the page to be returned (optional, default to 100) - * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order - * is ascending. Multiple sort criteria are supported. (optional) - * @param state (optional) - * @param searchTerm (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Successfully retrieved page of notifications-
400Bad request-
401Unauthorized-
403Forbidden-
404Not Found-
- */ - public okhttp3.Call getNotificationsAsync(Integer page, Integer size, List sort, String state, - String searchTerm, final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = getNotificationsValidateBeforeCall(page, size, sort, state, searchTerm, _callback); - Type localVarReturnType = new TypeToken() { - }.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - - /** - * Build call for updateNotificationStatusById - * @param id (required) - * @param operation (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Succeeded-
400Bad Request-
401Unauthorized-
404Not found-
- */ - public okhttp3.Call updateNotificationStatusByIdCall(UUID id, String operation, 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 = "/api/v1/notifications/{id}".replace("{" + "id" + "}", - localVarApiClient.escapeString(id.toString())); - - List localVarQueryParams = new ArrayList(); - List localVarCollectionQueryParams = new ArrayList(); - Map localVarHeaderParams = new HashMap(); - Map localVarCookieParams = new HashMap(); - Map localVarFormParams = new HashMap(); - - if (operation != null) { - localVarQueryParams.addAll(localVarApiClient.parameterToPair("operation", operation)); - } - - final String[] localVarAccepts = { "*/*" }; - final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); - if (localVarAccept != null) { - localVarHeaderParams.put("Accept", localVarAccept); - } - - final String[] localVarContentTypes = {}; - final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); - if (localVarContentType != null) { - localVarHeaderParams.put("Content-Type", localVarContentType); - } - - String[] localVarAuthNames = new String[] {}; - return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, - localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, - localVarFormParams, localVarAuthNames, _callback); - } - - @SuppressWarnings("rawtypes") - private okhttp3.Call updateNotificationStatusByIdValidateBeforeCall(UUID id, String operation, - final ApiCallback _callback) throws ApiException { - // verify the required parameter 'id' is set - if (id == null) { - throw new ApiException( - "Missing the required parameter 'id' when calling updateNotificationStatusById(Async)"); - } - - // verify the required parameter 'operation' is set - if (operation == null) { - throw new ApiException( - "Missing the required parameter 'operation' when calling updateNotificationStatusById(Async)"); - } - - return updateNotificationStatusByIdCall(id, operation, _callback); - - } - - /** - * Update the specified notification record with user operation - * @param id (required) - * @param operation (required) - * @return NotificationRecordResponseDTO - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Succeeded-
400Bad Request-
401Unauthorized-
404Not found-
- */ - public NotificationRecordResponseDTO updateNotificationStatusById(UUID id, String operation) throws ApiException { - ApiResponse localVarResp = updateNotificationStatusByIdWithHttpInfo(id, - operation); - return localVarResp.getData(); - } - - /** - * Update the specified notification record with user operation - * @param id (required) - * @param operation (required) - * @return ApiResponse<NotificationRecordResponseDTO> - * @throws ApiException If fail to call the API, e.g. server error or cannot - * deserialize the response body - * @http.response.details - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Succeeded-
400Bad Request-
401Unauthorized-
404Not found-
- */ - public ApiResponse updateNotificationStatusByIdWithHttpInfo(UUID id, - String operation) throws ApiException { - okhttp3.Call localVarCall = updateNotificationStatusByIdValidateBeforeCall(id, operation, null); - Type localVarReturnType = new TypeToken() { - }.getType(); - return localVarApiClient.execute(localVarCall, localVarReturnType); - } - - /** - * Update the specified notification record with user operation (asynchronously) - * @param id (required) - * @param operation (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 - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *
Status CodeDescriptionResponse Headers
200Succeeded-
400Bad Request-
401Unauthorized-
404Not found-
- */ - public okhttp3.Call updateNotificationStatusByIdAsync(UUID id, String operation, - final ApiCallback _callback) throws ApiException { - - okhttp3.Call localVarCall = updateNotificationStatusByIdValidateBeforeCall(id, operation, _callback); - Type localVarReturnType = new TypeToken() { - }.getType(); - localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); - return localVarCall; - } - + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public NotificationRecordApi() { + this(Configuration.getDefaultApiClient()); + } + + public NotificationRecordApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for countUnreadNotifications + * @param state (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call countUnreadNotificationsCall(String state, 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 = "/api/v1/notifications/count"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (state != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("state", state)); + } + + final String[] localVarAccepts = { + "*/*" + }; + 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 countUnreadNotificationsValidateBeforeCall(String state, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'state' is set + if (state == null) { + throw new ApiException("Missing the required parameter 'state' when calling countUnreadNotifications(Async)"); + } + + return countUnreadNotificationsCall(state, _callback); + + } + + /** + * Return the number of the unread notification records for the user + * + * @param state (required) + * @return Integer + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public Integer countUnreadNotifications(String state) throws ApiException { + ApiResponse localVarResp = countUnreadNotificationsWithHttpInfo(state); + return localVarResp.getData(); + } + + /** + * Return the number of the unread notification records for the user + * + * @param state (required) + * @return ApiResponse<Integer> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public ApiResponse countUnreadNotificationsWithHttpInfo(String state) throws ApiException { + okhttp3.Call localVarCall = countUnreadNotificationsValidateBeforeCall(state, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Return the number of the unread notification records for the user (asynchronously) + * + * @param state (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call countUnreadNotificationsAsync(String state, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = countUnreadNotificationsValidateBeforeCall(state, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteNotification + * @param id (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call deleteNotificationCall(UUID id, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/api/v1/notifications/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "*/*" + }; + 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 deleteNotificationValidateBeforeCall(UUID id, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling deleteNotification(Async)"); + } + + return deleteNotificationCall(id, _callback); + + } + + /** + * Delete the specified notification record + * + * @param id (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public void deleteNotification(UUID id) throws ApiException { + deleteNotificationWithHttpInfo(id); + } + + /** + * Delete the specified notification record + * + * @param id (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public ApiResponse deleteNotificationWithHttpInfo(UUID id) throws ApiException { + okhttp3.Call localVarCall = deleteNotificationValidateBeforeCall(id, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete the specified notification record (asynchronously) + * + * @param id (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved the amount of notifications -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call deleteNotificationAsync(UUID id, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteNotificationValidateBeforeCall(id, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for getNotifications + * @param page Zero-based page index (0..N) (optional, default to 0) + * @param size The size of the page to be returned (optional, default to 100) + * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported. (optional) + * @param state (optional) + * @param searchTerm (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved page of notifications -
400 Bad request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getNotificationsCall(Integer page, Integer size, List sort, String state, String searchTerm, 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 = "/api/v1/notifications"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (page != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("page", page)); + } + + if (size != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("size", size)); + } + + if (sort != null) { + localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("multi", "sort", sort)); + } + + if (state != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("state", state)); + } + + if (searchTerm != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("searchTerm", searchTerm)); + } + + final String[] localVarAccepts = { + "*/*" + }; + 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 getNotificationsValidateBeforeCall(Integer page, Integer size, List sort, String state, String searchTerm, final ApiCallback _callback) throws ApiException { + return getNotificationsCall(page, size, sort, state, searchTerm, _callback); + + } + + /** + * Return a list of notification records for the user + * + * @param page Zero-based page index (0..N) (optional, default to 0) + * @param size The size of the page to be returned (optional, default to 100) + * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported. (optional) + * @param state (optional) + * @param searchTerm (optional) + * @return PageNotificationRecordResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved page of notifications -
400 Bad request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public PageNotificationRecordResponseDTO getNotifications(Integer page, Integer size, List sort, String state, String searchTerm) throws ApiException { + ApiResponse localVarResp = getNotificationsWithHttpInfo(page, size, sort, state, searchTerm); + return localVarResp.getData(); + } + + /** + * Return a list of notification records for the user + * + * @param page Zero-based page index (0..N) (optional, default to 0) + * @param size The size of the page to be returned (optional, default to 100) + * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported. (optional) + * @param state (optional) + * @param searchTerm (optional) + * @return ApiResponse<PageNotificationRecordResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved page of notifications -
400 Bad request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public ApiResponse getNotificationsWithHttpInfo(Integer page, Integer size, List sort, String state, String searchTerm) throws ApiException { + okhttp3.Call localVarCall = getNotificationsValidateBeforeCall(page, size, sort, state, searchTerm, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Return a list of notification records for the user (asynchronously) + * + * @param page Zero-based page index (0..N) (optional, default to 0) + * @param size The size of the page to be returned (optional, default to 100) + * @param sort Sorting criteria in the format: property(,asc|desc). Default sort order is ascending. Multiple sort criteria are supported. (optional) + * @param state (optional) + * @param searchTerm (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 + + + + + + + +
Status Code Description Response Headers
200 Successfully retrieved page of notifications -
400 Bad request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
+ */ + public okhttp3.Call getNotificationsAsync(Integer page, Integer size, List sort, String state, String searchTerm, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getNotificationsValidateBeforeCall(page, size, sort, state, searchTerm, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for updateNotificationStatusById + * @param id (required) + * @param operation (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 + + + + + + +
Status Code Description Response Headers
200 Succeeded -
400 Bad Request -
401 Unauthorized -
404 Not found -
+ */ + public okhttp3.Call updateNotificationStatusByIdCall(UUID id, String operation, 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 = "/api/v1/notifications/{id}" + .replace("{" + "id" + "}", localVarApiClient.escapeString(id.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (operation != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("operation", operation)); + } + + final String[] localVarAccepts = { + "*/*" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateNotificationStatusByIdValidateBeforeCall(UUID id, String operation, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'id' is set + if (id == null) { + throw new ApiException("Missing the required parameter 'id' when calling updateNotificationStatusById(Async)"); + } + + // verify the required parameter 'operation' is set + if (operation == null) { + throw new ApiException("Missing the required parameter 'operation' when calling updateNotificationStatusById(Async)"); + } + + return updateNotificationStatusByIdCall(id, operation, _callback); + + } + + /** + * Update the specified notification record with user operation + * + * @param id (required) + * @param operation (required) + * @return NotificationRecordResponseDTO + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Succeeded -
400 Bad Request -
401 Unauthorized -
404 Not found -
+ */ + public NotificationRecordResponseDTO updateNotificationStatusById(UUID id, String operation) throws ApiException { + ApiResponse localVarResp = updateNotificationStatusByIdWithHttpInfo(id, operation); + return localVarResp.getData(); + } + + /** + * Update the specified notification record with user operation + * + * @param id (required) + * @param operation (required) + * @return ApiResponse<NotificationRecordResponseDTO> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + +
Status Code Description Response Headers
200 Succeeded -
400 Bad Request -
401 Unauthorized -
404 Not found -
+ */ + public ApiResponse updateNotificationStatusByIdWithHttpInfo(UUID id, String operation) throws ApiException { + okhttp3.Call localVarCall = updateNotificationStatusByIdValidateBeforeCall(id, operation, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Update the specified notification record with user operation (asynchronously) + * + * @param id (required) + * @param operation (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 + + + + + + +
Status Code Description Response Headers
200 Succeeded -
400 Bad Request -
401 Unauthorized -
404 Not found -
+ */ + public okhttp3.Call updateNotificationStatusByIdAsync(UUID id, String operation, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateNotificationStatusByIdValidateBeforeCall(id, operation, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Pair.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Pair.java index cd5b850a0..d7b2f05e6 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Pair.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/Pair.java @@ -3,57 +3,55 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Pair { + private String name = ""; + private String value = ""; - private String name = ""; - - private String value = ""; - - public Pair(String name, String value) { - setName(name); - setValue(value); - } - - private void setName(String name) { - if (!isValidString(name)) { - return; - } + public Pair (String name, String value) { + setName(name); + setValue(value); + } - this.name = name; - } + private void setName(String name) { + if (!isValidString(name)) { + return; + } - private void setValue(String value) { - if (!isValidString(value)) { - return; - } + this.name = name; + } - this.value = value; - } + private void setValue(String value) { + if (!isValidString(value)) { + return; + } - public String getName() { - return this.name; - } + this.value = value; + } - public String getValue() { - return this.value; - } + public String getName() { + return this.name; + } - private boolean isValidString(String arg) { - if (arg == null) { - return false; - } + public String getValue() { + return this.value; + } - return true; - } + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + return true; + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressRequestBody.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressRequestBody.java index a0faf1ecd..1dbc75fdd 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressRequestBody.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressRequestBody.java @@ -3,19 +3,21 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.io.IOException; +package com.redhat.parodos.notification.sdk.api; import okhttp3.MediaType; import okhttp3.RequestBody; + +import java.io.IOException; + import okio.Buffer; import okio.BufferedSink; import okio.ForwardingSink; @@ -24,50 +26,48 @@ 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); - } - }; - } - + 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressResponseBody.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressResponseBody.java index ea58b037c..393e12b21 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressResponseBody.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ProgressResponseBody.java @@ -3,19 +3,21 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; -import java.io.IOException; +package com.redhat.parodos.notification.sdk.api; import okhttp3.MediaType; import okhttp3.ResponseBody; + +import java.io.IOException; + import okio.Buffer; import okio.BufferedSource; import okio.ForwardingSource; @@ -24,49 +26,45 @@ 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; - } + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; - @Override - public MediaType contentType() { - return responseBody.contentType(); - } + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } - @Override - public long contentLength() { - return responseBody.contentLength(); - } + @Override + public MediaType contentType() { + return responseBody.contentType(); + } - @Override - public BufferedSource source() { - if (bufferedSource == null) { - bufferedSource = Okio.buffer(source(responseBody.source())); - } - return bufferedSource; - } + @Override + public long contentLength() { + return responseBody.contentLength(); + } - private Source source(Source source) { - return new ForwardingSource(source) { - long totalBytesRead = 0L; + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } - @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; - } - }; - } + 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerConfiguration.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerConfiguration.java index f3eeef887..20bfefb61 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerConfiguration.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerConfiguration.java @@ -6,57 +6,53 @@ * Representing a Server configuration. */ 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); - } - + 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerVariable.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerVariable.java index 287172eb2..608195e94 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerVariable.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/ServerVariable.java @@ -6,23 +6,18 @@ * Representing a Server Variable for server URL template substitution. */ public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; - 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; - } - + /** + * @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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/StringUtil.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/StringUtil.java index 60773a89f..74e322b1b 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/StringUtil.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/StringUtil.java @@ -3,13 +3,14 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api; import java.util.Collection; @@ -17,66 +18,66 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") 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; + } - /** - * 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 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 ""; + } - /** - * 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(); - } + 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/ApiKeyAuth.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/ApiKeyAuth.java index 970e3254e..192a29fad 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/ApiKeyAuth.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/ApiKeyAuth.java @@ -3,84 +3,78 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api.auth; -import java.net.URI; -import java.util.List; -import java.util.Map; +package com.redhat.parodos.notification.sdk.api.auth; import com.redhat.parodos.notification.sdk.api.ApiException; import com.redhat.parodos.notification.sdk.api.Pair; +import java.net.URI; +import java.util.Map; +import java.util.List; + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ApiKeyAuth implements Authentication { - - private final String location; - - private final String paramName; - - private String apiKey; - - private String apiKeyPrefix; - - public ApiKeyAuth(String location, String paramName) { - this.location = location; - this.paramName = paramName; - } - - public String getLocation() { - return location; - } - - public String getParamName() { - return paramName; - } - - public String getApiKey() { - return apiKey; - } - - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - } - - public String getApiKeyPrefix() { - return apiKeyPrefix; - } - - public void setApiKeyPrefix(String apiKeyPrefix) { - this.apiKeyPrefix = apiKeyPrefix; - } - - @Override - public void applyToParams(List queryParams, Map headerParams, - Map cookieParams, String payload, String method, URI uri) throws ApiException { - if (apiKey == null) { - return; - } - String value; - if (apiKeyPrefix != null) { - value = apiKeyPrefix + " " + apiKey; - } - else { - value = apiKey; - } - if ("query".equals(location)) { - queryParams.add(new Pair(paramName, value)); - } - else if ("header".equals(location)) { - headerParams.put(paramName, value); - } - else if ("cookie".equals(location)) { - cookieParams.put(paramName, value); - } - } - + private final String location; + private final String paramName; + + private String apiKey; + private String apiKeyPrefix; + + public ApiKeyAuth(String location, String paramName) { + this.location = location; + this.paramName = paramName; + } + + public String getLocation() { + return location; + } + + public String getParamName() { + return paramName; + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + } + + public String getApiKeyPrefix() { + return apiKeyPrefix; + } + + public void setApiKeyPrefix(String apiKeyPrefix) { + this.apiKeyPrefix = apiKeyPrefix; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (apiKey == null) { + return; + } + String value; + if (apiKeyPrefix != null) { + value = apiKeyPrefix + " " + apiKey; + } else { + value = apiKey; + } + if ("query".equals(location)) { + queryParams.add(new Pair(paramName, value)); + } else if ("header".equals(location)) { + headerParams.put(paramName, value); + } else if ("cookie".equals(location)) { + cookieParams.put(paramName, value); + } + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/Authentication.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/Authentication.java index a2038229f..958d71ce4 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/Authentication.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/Authentication.java @@ -3,35 +3,34 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api.auth; +import com.redhat.parodos.notification.sdk.api.Pair; +import com.redhat.parodos.notification.sdk.api.ApiException; + import java.net.URI; -import java.util.List; import java.util.Map; - -import com.redhat.parodos.notification.sdk.api.ApiException; -import com.redhat.parodos.notification.sdk.api.Pair; +import java.util.List; public interface Authentication { - - /** - * Apply authentication settings to header and query params. - * @param queryParams List of query parameters - * @param headerParams Map of header parameters - * @param cookieParams Map of cookie parameters - * @param payload HTTP request body - * @param method HTTP method - * @param uri URI - * @throws ApiException if failed to update the parameters - */ - void applyToParams(List queryParams, Map headerParams, Map cookieParams, - String payload, String method, URI uri) throws ApiException; - + /** + * Apply authentication settings to header and query params. + * + * @param queryParams List of query parameters + * @param headerParams Map of header parameters + * @param cookieParams Map of cookie parameters + * @param payload HTTP request body + * @param method HTTP method + * @param uri URI + * @throws ApiException if failed to update the parameters + */ + void applyToParams(List queryParams, Map headerParams, Map cookieParams, String payload, String method, URI uri) throws ApiException; } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBasicAuth.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBasicAuth.java index 41c8157bc..26083a3b8 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBasicAuth.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBasicAuth.java @@ -3,53 +3,55 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api.auth; -import java.net.URI; -import java.util.List; -import java.util.Map; +package com.redhat.parodos.notification.sdk.api.auth; -import com.redhat.parodos.notification.sdk.api.ApiException; import com.redhat.parodos.notification.sdk.api.Pair; -import okhttp3.Credentials; - -public class HttpBasicAuth implements Authentication { - - private String username; - - private String password; - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } +import com.redhat.parodos.notification.sdk.api.ApiException; - public String getPassword() { - return password; - } +import okhttp3.Credentials; - public void setPassword(String password) { - this.password = password; - } +import java.net.URI; +import java.util.Map; +import java.util.List; - @Override - public void applyToParams(List queryParams, Map headerParams, - Map cookieParams, String payload, String method, URI uri) throws ApiException { - if (username == null && password == null) { - return; - } - headerParams.put("Authorization", - Credentials.basic(username == null ? "" : username, password == null ? "" : password)); - } +import java.io.UnsupportedEncodingException; +public class HttpBasicAuth implements Authentication { + private String username; + private String password; + + public String getUsername() { + return username; + } + + public void setUsername(String username) { + this.username = username; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (username == null && password == null) { + return; + } + headerParams.put("Authorization", Credentials.basic( + username == null ? "" : username, + password == null ? "" : password)); + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBearerAuth.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBearerAuth.java index bb73fbfcf..395767993 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBearerAuth.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/api/auth/HttpBearerAuth.java @@ -3,63 +3,61 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.api.auth; -import java.net.URI; -import java.util.List; -import java.util.Map; +package com.redhat.parodos.notification.sdk.api.auth; import com.redhat.parodos.notification.sdk.api.ApiException; import com.redhat.parodos.notification.sdk.api.Pair; +import java.net.URI; +import java.util.Map; +import java.util.List; + @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class HttpBearerAuth implements Authentication { - - private final String scheme; - - private String bearerToken; - - public HttpBearerAuth(String scheme) { - this.scheme = scheme; - } - - /** - * Gets the token, which together with the scheme, will be sent as the value of the - * Authorization header. - * @return The bearer token - */ - public String getBearerToken() { - return bearerToken; - } - - /** - * Sets the token, which together with the scheme, will be sent as the value of the - * Authorization header. - * @param bearerToken The bearer token to send in the Authorization header - */ - public void setBearerToken(String bearerToken) { - this.bearerToken = bearerToken; - } - - @Override - public void applyToParams(List queryParams, Map headerParams, - Map cookieParams, String payload, String method, URI uri) throws ApiException { - if (bearerToken == null) { - return; - } - - headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); - } - - private static String upperCaseBearer(String scheme) { - return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; - } - + private final String scheme; + private String bearerToken; + + public HttpBearerAuth(String scheme) { + this.scheme = scheme; + } + + /** + * Gets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @return The bearer token + */ + public String getBearerToken() { + return bearerToken; + } + + /** + * Sets the token, which together with the scheme, will be sent as the value of the Authorization header. + * + * @param bearerToken The bearer token to send in the Authorization header + */ + public void setBearerToken(String bearerToken) { + this.bearerToken = bearerToken; + } + + @Override + public void applyToParams(List queryParams, Map headerParams, Map cookieParams, + String payload, String method, URI uri) throws ApiException { + if (bearerToken == null) { + return; + } + + headerParams.put("Authorization", (scheme != null ? upperCaseBearer(scheme) + " " : "") + bearerToken); + } + + private static String upperCaseBearer(String scheme) { + return ("bearer".equalsIgnoreCase(scheme)) ? "Bearer" : scheme; + } } diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/AbstractOpenApiSchema.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/AbstractOpenApiSchema.java index a6d524517..d1d9f9536 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/AbstractOpenApiSchema.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/AbstractOpenApiSchema.java @@ -3,18 +3,20 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; -import java.util.Map; +import com.redhat.parodos.notification.sdk.api.ApiException; import java.util.Objects; - +import java.lang.reflect.Type; +import java.util.Map; import javax.ws.rs.core.GenericType; //import com.fasterxml.jackson.annotation.JsonValue; @@ -25,122 +27,123 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") 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; - } - } + // 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/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/ErrorMessageDTO.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/ErrorMessageDTO.java index d22dbb5d4..a7f3e6f07 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/ErrorMessageDTO.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/ErrorMessageDTO.java @@ -3,31 +3,45 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.Date; -import java.util.HashSet; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -35,228 +49,219 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class ErrorMessageDTO { - - public static final String SERIALIZED_NAME_DATE = "date"; - - @SerializedName(SERIALIZED_NAME_DATE) - private Date date; - - public static final String SERIALIZED_NAME_DESCRIPTION = "description"; - - @SerializedName(SERIALIZED_NAME_DESCRIPTION) - private String description; - - public static final String SERIALIZED_NAME_MESSAGE = "message"; - - @SerializedName(SERIALIZED_NAME_MESSAGE) - private String message; - - public ErrorMessageDTO() { - } - - public ErrorMessageDTO date(Date date) { - - this.date = date; - return this; - } - - /** - * Get date - * @return date - **/ - @javax.annotation.Nullable - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public ErrorMessageDTO description(String description) { - - this.description = description; - return this; - } - - /** - * Get description - * @return description - **/ - @javax.annotation.Nullable - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public ErrorMessageDTO message(String message) { - - this.message = message; - return this; - } - - /** - * Get message - * @return message - **/ - @javax.annotation.Nullable - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ErrorMessageDTO errorMessageDTO = (ErrorMessageDTO) o; - return Objects.equals(this.date, errorMessageDTO.date) - && Objects.equals(this.description, errorMessageDTO.description) - && Objects.equals(this.message, errorMessageDTO.message); - } - - @Override - public int hashCode() { - return Objects.hash(date, description, message); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class ErrorMessageDTO {\n"); - sb.append(" date: ").append(toIndentedString(date)).append("\n"); - sb.append(" description: ").append(toIndentedString(description)).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(); - openapiFields.add("date"); - openapiFields.add("description"); - openapiFields.add("message"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to ErrorMessageDTO - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!ErrorMessageDTO.openapiRequiredFields.isEmpty()) { // has required fields - // but JSON object is - // null - throw new IllegalArgumentException(String.format( - "The required field(s) %s in ErrorMessageDTO is not found in the empty JSON string", - ErrorMessageDTO.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!ErrorMessageDTO.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `ErrorMessageDTO` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - 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("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 (!ErrorMessageDTO.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'ErrorMessageDTO' and its - // subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, - TypeToken.get(ErrorMessageDTO.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, ErrorMessageDTO value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public ErrorMessageDTO read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of ErrorMessageDTO given an JSON string - * @param jsonString JSON string - * @return An instance of ErrorMessageDTO - * @throws IOException if the JSON string is invalid with respect to ErrorMessageDTO - */ - public static ErrorMessageDTO fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, ErrorMessageDTO.class); - } - - /** - * Convert an instance of ErrorMessageDTO to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } - + public static final String SERIALIZED_NAME_DATE = "date"; + @SerializedName(SERIALIZED_NAME_DATE) + private Date date; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + private String description; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public ErrorMessageDTO() { + } + + public ErrorMessageDTO date(Date date) { + + this.date = date; + return this; + } + + /** + * Get date + * @return date + **/ + @javax.annotation.Nullable + + public Date getDate() { + return date; + } + + + public void setDate(Date date) { + this.date = date; + } + + + public ErrorMessageDTO description(String description) { + + this.description = description; + return this; + } + + /** + * Get description + * @return description + **/ + @javax.annotation.Nullable + + public String getDescription() { + return description; + } + + + public void setDescription(String description) { + this.description = description; + } + + + public ErrorMessageDTO message(String message) { + + this.message = message; + return this; + } + + /** + * Get message + * @return message + **/ + @javax.annotation.Nullable + + public String getMessage() { + return message; + } + + + public void setMessage(String message) { + this.message = message; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorMessageDTO errorMessageDTO = (ErrorMessageDTO) o; + return Objects.equals(this.date, errorMessageDTO.date) && + Objects.equals(this.description, errorMessageDTO.description) && + Objects.equals(this.message, errorMessageDTO.message); + } + + @Override + public int hashCode() { + return Objects.hash(date, description, message); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorMessageDTO {\n"); + sb.append(" date: ").append(toIndentedString(date)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).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(); + openapiFields.add("date"); + openapiFields.add("description"); + openapiFields.add("message"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to ErrorMessageDTO + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!ErrorMessageDTO.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in ErrorMessageDTO is not found in the empty JSON string", ErrorMessageDTO.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!ErrorMessageDTO.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ErrorMessageDTO` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + 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("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 (!ErrorMessageDTO.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorMessageDTO' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorMessageDTO.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorMessageDTO value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public ErrorMessageDTO read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorMessageDTO given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorMessageDTO + * @throws IOException if the JSON string is invalid with respect to ErrorMessageDTO + */ + public static ErrorMessageDTO fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorMessageDTO.class); + } + + /** + * Convert an instance of ErrorMessageDTO to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Link.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Link.java index 33ed22c8d..a72b90972 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Link.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Link.java @@ -3,30 +3,44 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; -import java.io.IOException; -import java.util.HashSet; -import java.util.Map.Entry; import java.util.Objects; -import java.util.Set; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -34,430 +48,414 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Link { + public static final String SERIALIZED_NAME_DEPRECATION = "deprecation"; + @SerializedName(SERIALIZED_NAME_DEPRECATION) + private String deprecation; + + public static final String SERIALIZED_NAME_HREF = "href"; + @SerializedName(SERIALIZED_NAME_HREF) + private String href; - public static final String SERIALIZED_NAME_DEPRECATION = "deprecation"; + public static final String SERIALIZED_NAME_HREFLANG = "hreflang"; + @SerializedName(SERIALIZED_NAME_HREFLANG) + private String hreflang; - @SerializedName(SERIALIZED_NAME_DEPRECATION) - private String deprecation; + public static final String SERIALIZED_NAME_MEDIA = "media"; + @SerializedName(SERIALIZED_NAME_MEDIA) + private String media; - public static final String SERIALIZED_NAME_HREF = "href"; + public static final String SERIALIZED_NAME_NAME = "name"; + @SerializedName(SERIALIZED_NAME_NAME) + private String name; - @SerializedName(SERIALIZED_NAME_HREF) - private String href; + public static final String SERIALIZED_NAME_PROFILE = "profile"; + @SerializedName(SERIALIZED_NAME_PROFILE) + private String profile; - public static final String SERIALIZED_NAME_HREFLANG = "hreflang"; + public static final String SERIALIZED_NAME_REL = "rel"; + @SerializedName(SERIALIZED_NAME_REL) + private String rel; - @SerializedName(SERIALIZED_NAME_HREFLANG) - private String hreflang; + public static final String SERIALIZED_NAME_TITLE = "title"; + @SerializedName(SERIALIZED_NAME_TITLE) + private String title; - public static final String SERIALIZED_NAME_MEDIA = "media"; + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + private String type; - @SerializedName(SERIALIZED_NAME_MEDIA) - private String media; + public Link() { + } - public static final String SERIALIZED_NAME_NAME = "name"; + public Link deprecation(String deprecation) { + + this.deprecation = deprecation; + return this; + } - @SerializedName(SERIALIZED_NAME_NAME) - private String name; + /** + * Get deprecation + * @return deprecation + **/ + @javax.annotation.Nullable - public static final String SERIALIZED_NAME_PROFILE = "profile"; + public String getDeprecation() { + return deprecation; + } - @SerializedName(SERIALIZED_NAME_PROFILE) - private String profile; - public static final String SERIALIZED_NAME_REL = "rel"; + public void setDeprecation(String deprecation) { + this.deprecation = deprecation; + } - @SerializedName(SERIALIZED_NAME_REL) - private String rel; - public static final String SERIALIZED_NAME_TITLE = "title"; + public Link href(String href) { + + this.href = href; + return this; + } - @SerializedName(SERIALIZED_NAME_TITLE) - private String title; + /** + * Get href + * @return href + **/ + @javax.annotation.Nullable - public static final String SERIALIZED_NAME_TYPE = "type"; + public String getHref() { + return href; + } - @SerializedName(SERIALIZED_NAME_TYPE) - private String type; - public Link() { - } + public void setHref(String href) { + this.href = href; + } - public Link deprecation(String deprecation) { - this.deprecation = deprecation; - return this; - } + public Link hreflang(String hreflang) { + + this.hreflang = hreflang; + return this; + } - /** - * Get deprecation - * @return deprecation - **/ - @javax.annotation.Nullable + /** + * Get hreflang + * @return hreflang + **/ + @javax.annotation.Nullable - public String getDeprecation() { - return deprecation; - } + public String getHreflang() { + return hreflang; + } - public void setDeprecation(String deprecation) { - this.deprecation = deprecation; - } - public Link href(String href) { + public void setHreflang(String hreflang) { + this.hreflang = hreflang; + } - this.href = href; - return this; - } - /** - * Get href - * @return href - **/ - @javax.annotation.Nullable + public Link media(String media) { + + this.media = media; + return this; + } - public String getHref() { - return href; - } + /** + * Get media + * @return media + **/ + @javax.annotation.Nullable - public void setHref(String href) { - this.href = href; - } + public String getMedia() { + return media; + } - public Link hreflang(String hreflang) { - this.hreflang = hreflang; - return this; - } + public void setMedia(String media) { + this.media = media; + } - /** - * Get hreflang - * @return hreflang - **/ - @javax.annotation.Nullable - public String getHreflang() { - return hreflang; - } + public Link name(String name) { + + this.name = name; + return this; + } - public void setHreflang(String hreflang) { - this.hreflang = hreflang; - } + /** + * Get name + * @return name + **/ + @javax.annotation.Nullable - public Link media(String media) { + public String getName() { + return name; + } - this.media = media; - return this; - } - /** - * Get media - * @return media - **/ - @javax.annotation.Nullable + public void setName(String name) { + this.name = name; + } - public String getMedia() { - return media; - } - public void setMedia(String media) { - this.media = media; - } + public Link profile(String profile) { + + this.profile = profile; + return this; + } - public Link name(String name) { + /** + * Get profile + * @return profile + **/ + @javax.annotation.Nullable - this.name = name; - return this; - } + public String getProfile() { + return profile; + } - /** - * Get name - * @return name - **/ - @javax.annotation.Nullable - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public Link profile(String profile) { - - this.profile = profile; - return this; - } - - /** - * Get profile - * @return profile - **/ - @javax.annotation.Nullable - - public String getProfile() { - return profile; - } - - public void setProfile(String profile) { - this.profile = profile; - } - - public Link rel(String rel) { - - this.rel = rel; - return this; - } - - /** - * Get rel - * @return rel - **/ - @javax.annotation.Nullable - - public String getRel() { - return rel; - } - - public void setRel(String rel) { - this.rel = rel; - } - - public Link title(String title) { - - this.title = title; - return this; - } - - /** - * Get title - * @return title - **/ - @javax.annotation.Nullable - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public Link type(String type) { - - this.type = type; - return this; - } - - /** - * Get type - * @return type - **/ - @javax.annotation.Nullable - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Link link = (Link) o; - return Objects.equals(this.deprecation, link.deprecation) && Objects.equals(this.href, link.href) - && Objects.equals(this.hreflang, link.hreflang) && Objects.equals(this.media, link.media) - && Objects.equals(this.name, link.name) && Objects.equals(this.profile, link.profile) - && Objects.equals(this.rel, link.rel) && Objects.equals(this.title, link.title) - && Objects.equals(this.type, link.type); - } - - @Override - public int hashCode() { - return Objects.hash(deprecation, href, hreflang, media, name, profile, rel, title, type); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Link {\n"); - sb.append(" deprecation: ").append(toIndentedString(deprecation)).append("\n"); - sb.append(" href: ").append(toIndentedString(href)).append("\n"); - sb.append(" hreflang: ").append(toIndentedString(hreflang)).append("\n"); - sb.append(" media: ").append(toIndentedString(media)).append("\n"); - sb.append(" name: ").append(toIndentedString(name)).append("\n"); - sb.append(" profile: ").append(toIndentedString(profile)).append("\n"); - sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); - sb.append(" title: ").append(toIndentedString(title)).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(); - openapiFields.add("deprecation"); - openapiFields.add("href"); - openapiFields.add("hreflang"); - openapiFields.add("media"); - openapiFields.add("name"); - openapiFields.add("profile"); - openapiFields.add("rel"); - openapiFields.add("title"); - openapiFields.add("type"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Link - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!Link.openapiRequiredFields.isEmpty()) { // has required fields but JSON - // object is null - throw new IllegalArgumentException( - String.format("The required field(s) %s in Link is not found in the empty JSON string", - Link.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Link.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `Link` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - if ((jsonObj.get("deprecation") != null && !jsonObj.get("deprecation").isJsonNull()) - && !jsonObj.get("deprecation").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `deprecation` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("deprecation").toString())); - } - if ((jsonObj.get("href") != null && !jsonObj.get("href").isJsonNull()) - && !jsonObj.get("href").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `href` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("href").toString())); - } - if ((jsonObj.get("hreflang") != null && !jsonObj.get("hreflang").isJsonNull()) - && !jsonObj.get("hreflang").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `hreflang` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("hreflang").toString())); - } - if ((jsonObj.get("media") != null && !jsonObj.get("media").isJsonNull()) - && !jsonObj.get("media").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `media` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("media").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("profile") != null && !jsonObj.get("profile").isJsonNull()) - && !jsonObj.get("profile").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `profile` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("profile").toString())); - } - if ((jsonObj.get("rel") != null && !jsonObj.get("rel").isJsonNull()) && !jsonObj.get("rel").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `rel` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("rel").toString())); - } - if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) - && !jsonObj.get("title").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("title").toString())); - } - if ((jsonObj.get("type") != 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 (!Link.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Link' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(Link.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Link value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Link read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of Link given an JSON string - * @param jsonString JSON string - * @return An instance of Link - * @throws IOException if the JSON string is invalid with respect to Link - */ - public static Link fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Link.class); - } - - /** - * Convert an instance of Link to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } + public void setProfile(String profile) { + this.profile = profile; + } + + + public Link rel(String rel) { + + this.rel = rel; + return this; + } + + /** + * Get rel + * @return rel + **/ + @javax.annotation.Nullable + + public String getRel() { + return rel; + } + + + public void setRel(String rel) { + this.rel = rel; + } + + + public Link title(String title) { + + this.title = title; + return this; + } + + /** + * Get title + * @return title + **/ + @javax.annotation.Nullable + + public String getTitle() { + return title; + } + + + public void setTitle(String title) { + this.title = title; + } + + + public Link type(String type) { + + this.type = type; + return this; + } + + /** + * Get type + * @return type + **/ + @javax.annotation.Nullable + + public String getType() { + return type; + } + + + public void setType(String type) { + this.type = type; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link link = (Link) o; + return Objects.equals(this.deprecation, link.deprecation) && + Objects.equals(this.href, link.href) && + Objects.equals(this.hreflang, link.hreflang) && + Objects.equals(this.media, link.media) && + Objects.equals(this.name, link.name) && + Objects.equals(this.profile, link.profile) && + Objects.equals(this.rel, link.rel) && + Objects.equals(this.title, link.title) && + Objects.equals(this.type, link.type); + } + + @Override + public int hashCode() { + return Objects.hash(deprecation, href, hreflang, media, name, profile, rel, title, type); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Link {\n"); + sb.append(" deprecation: ").append(toIndentedString(deprecation)).append("\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" hreflang: ").append(toIndentedString(hreflang)).append("\n"); + sb.append(" media: ").append(toIndentedString(media)).append("\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" profile: ").append(toIndentedString(profile)).append("\n"); + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" title: ").append(toIndentedString(title)).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(); + openapiFields.add("deprecation"); + openapiFields.add("href"); + openapiFields.add("hreflang"); + openapiFields.add("media"); + openapiFields.add("name"); + openapiFields.add("profile"); + openapiFields.add("rel"); + openapiFields.add("title"); + openapiFields.add("type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Link + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Link.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Link is not found in the empty JSON string", Link.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Link.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Link` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("deprecation") != null && !jsonObj.get("deprecation").isJsonNull()) && !jsonObj.get("deprecation").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `deprecation` to be a primitive type in the JSON string but got `%s`", jsonObj.get("deprecation").toString())); + } + if ((jsonObj.get("href") != null && !jsonObj.get("href").isJsonNull()) && !jsonObj.get("href").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `href` to be a primitive type in the JSON string but got `%s`", jsonObj.get("href").toString())); + } + if ((jsonObj.get("hreflang") != null && !jsonObj.get("hreflang").isJsonNull()) && !jsonObj.get("hreflang").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `hreflang` to be a primitive type in the JSON string but got `%s`", jsonObj.get("hreflang").toString())); + } + if ((jsonObj.get("media") != null && !jsonObj.get("media").isJsonNull()) && !jsonObj.get("media").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `media` to be a primitive type in the JSON string but got `%s`", jsonObj.get("media").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("profile") != null && !jsonObj.get("profile").isJsonNull()) && !jsonObj.get("profile").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `profile` to be a primitive type in the JSON string but got `%s`", jsonObj.get("profile").toString())); + } + if ((jsonObj.get("rel") != null && !jsonObj.get("rel").isJsonNull()) && !jsonObj.get("rel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `rel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rel").toString())); + } + if ((jsonObj.get("title") != null && !jsonObj.get("title").isJsonNull()) && !jsonObj.get("title").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `title` to be a primitive type in the JSON string but got `%s`", jsonObj.get("title").toString())); + } + if ((jsonObj.get("type") != 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 (!Link.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Link' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Link.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Link value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Link read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Link given an JSON string + * + * @param jsonString JSON string + * @return An instance of Link + * @throws IOException if the JSON string is invalid with respect to Link + */ + public static Link fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Link.class); + } + + /** + * Convert an instance of Link to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationMessageCreateRequestDTO.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationMessageCreateRequestDTO.java index 7a6457bb3..c750b93da 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationMessageCreateRequestDTO.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationMessageCreateRequestDTO.java @@ -3,32 +3,46 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -36,325 +50,304 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class NotificationMessageCreateRequestDTO { + public static final String SERIALIZED_NAME_BODY = "body"; + @SerializedName(SERIALIZED_NAME_BODY) + private String body; - public static final String SERIALIZED_NAME_BODY = "body"; - - @SerializedName(SERIALIZED_NAME_BODY) - private String body; - - public static final String SERIALIZED_NAME_GROUP_NAMES = "groupNames"; - - @SerializedName(SERIALIZED_NAME_GROUP_NAMES) - private List groupNames = new ArrayList<>(); + public static final String SERIALIZED_NAME_GROUP_NAMES = "groupNames"; + @SerializedName(SERIALIZED_NAME_GROUP_NAMES) + private List groupNames = new ArrayList<>(); + + public static final String SERIALIZED_NAME_MESSAGE_TYPE = "messageType"; + @SerializedName(SERIALIZED_NAME_MESSAGE_TYPE) + private String messageType; + + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + private String subject; - public static final String SERIALIZED_NAME_MESSAGE_TYPE = "messageType"; + public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + @SerializedName(SERIALIZED_NAME_USERNAMES) + private List usernames = new ArrayList<>(); - @SerializedName(SERIALIZED_NAME_MESSAGE_TYPE) - private String messageType; + public NotificationMessageCreateRequestDTO() { + } - public static final String SERIALIZED_NAME_SUBJECT = "subject"; + public NotificationMessageCreateRequestDTO body(String body) { + + this.body = body; + return this; + } - @SerializedName(SERIALIZED_NAME_SUBJECT) - private String subject; + /** + * Get body + * @return body + **/ + @javax.annotation.Nullable - public static final String SERIALIZED_NAME_USERNAMES = "usernames"; + public String getBody() { + return body; + } - @SerializedName(SERIALIZED_NAME_USERNAMES) - private List usernames = new ArrayList<>(); - public NotificationMessageCreateRequestDTO() { - } + public void setBody(String body) { + this.body = body; + } + - public NotificationMessageCreateRequestDTO body(String body) { + public NotificationMessageCreateRequestDTO groupNames(List groupNames) { + + this.groupNames = groupNames; + return this; + } - this.body = body; - return this; - } - - /** - * Get body - * @return body - **/ - @javax.annotation.Nullable - - public String getBody() { - return body; - } - - public void setBody(String body) { - this.body = body; - } - - public NotificationMessageCreateRequestDTO groupNames(List groupNames) { - - this.groupNames = groupNames; - return this; - } - - public NotificationMessageCreateRequestDTO addGroupNamesItem(String groupNamesItem) { - if (this.groupNames == null) { - this.groupNames = new ArrayList<>(); - } - this.groupNames.add(groupNamesItem); - return this; - } - - /** - * Get groupNames - * @return groupNames - **/ - @javax.annotation.Nullable - - public List getGroupNames() { - return groupNames; - } - - public void setGroupNames(List groupNames) { - this.groupNames = groupNames; - } - - public NotificationMessageCreateRequestDTO messageType(String messageType) { - - this.messageType = messageType; - return this; - } - - /** - * Get messageType - * @return messageType - **/ - @javax.annotation.Nullable - - public String getMessageType() { - return messageType; - } - - public void setMessageType(String messageType) { - this.messageType = messageType; - } - - public NotificationMessageCreateRequestDTO subject(String subject) { - - this.subject = subject; - return this; - } - - /** - * Get subject - * @return subject - **/ - @javax.annotation.Nullable - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public NotificationMessageCreateRequestDTO usernames(List usernames) { - - this.usernames = usernames; - return this; - } - - public NotificationMessageCreateRequestDTO addUsernamesItem(String usernamesItem) { - if (this.usernames == null) { - this.usernames = new ArrayList<>(); - } - this.usernames.add(usernamesItem); - return this; - } - - /** - * Get usernames - * @return usernames - **/ - @javax.annotation.Nullable - - public List getUsernames() { - return usernames; - } - - public void setUsernames(List usernames) { - this.usernames = usernames; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO = (NotificationMessageCreateRequestDTO) o; - return Objects.equals(this.body, notificationMessageCreateRequestDTO.body) - && Objects.equals(this.groupNames, notificationMessageCreateRequestDTO.groupNames) - && Objects.equals(this.messageType, notificationMessageCreateRequestDTO.messageType) - && Objects.equals(this.subject, notificationMessageCreateRequestDTO.subject) - && Objects.equals(this.usernames, notificationMessageCreateRequestDTO.usernames); - } - - @Override - public int hashCode() { - return Objects.hash(body, groupNames, messageType, subject, usernames); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NotificationMessageCreateRequestDTO {\n"); - sb.append(" body: ").append(toIndentedString(body)).append("\n"); - sb.append(" groupNames: ").append(toIndentedString(groupNames)).append("\n"); - sb.append(" messageType: ").append(toIndentedString(messageType)).append("\n"); - sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); - sb.append(" usernames: ").append(toIndentedString(usernames)).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(); - openapiFields.add("body"); - openapiFields.add("groupNames"); - openapiFields.add("messageType"); - openapiFields.add("subject"); - openapiFields.add("usernames"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to - * NotificationMessageCreateRequestDTO - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!NotificationMessageCreateRequestDTO.openapiRequiredFields.isEmpty()) { // has - // required - // fields - // but - // JSON - // object - // is - // null - throw new IllegalArgumentException(String.format( - "The required field(s) %s in NotificationMessageCreateRequestDTO is not found in the empty JSON string", - NotificationMessageCreateRequestDTO.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NotificationMessageCreateRequestDTO.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `NotificationMessageCreateRequestDTO` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - if ((jsonObj.get("body") != null && !jsonObj.get("body").isJsonNull()) - && !jsonObj.get("body").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `body` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("body").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("groupNames") != null && !jsonObj.get("groupNames").isJsonArray()) { - throw new IllegalArgumentException( - String.format("Expected the field `groupNames` to be an array in the JSON string but got `%s`", - jsonObj.get("groupNames").toString())); - } - if ((jsonObj.get("messageType") != null && !jsonObj.get("messageType").isJsonNull()) - && !jsonObj.get("messageType").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `messageType` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("messageType").toString())); - } - if ((jsonObj.get("subject") != null && !jsonObj.get("subject").isJsonNull()) - && !jsonObj.get("subject").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("subject").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonArray()) { - throw new IllegalArgumentException( - String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", - jsonObj.get("usernames").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NotificationMessageCreateRequestDTO.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes - // 'NotificationMessageCreateRequestDTO' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, - TypeToken.get(NotificationMessageCreateRequestDTO.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NotificationMessageCreateRequestDTO value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NotificationMessageCreateRequestDTO read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of NotificationMessageCreateRequestDTO given an JSON string - * @param jsonString JSON string - * @return An instance of NotificationMessageCreateRequestDTO - * @throws IOException if the JSON string is invalid with respect to - * NotificationMessageCreateRequestDTO - */ - public static NotificationMessageCreateRequestDTO fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NotificationMessageCreateRequestDTO.class); - } - - /** - * Convert an instance of NotificationMessageCreateRequestDTO to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } + public NotificationMessageCreateRequestDTO addGroupNamesItem(String groupNamesItem) { + if (this.groupNames == null) { + this.groupNames = new ArrayList<>(); + } + this.groupNames.add(groupNamesItem); + return this; + } + /** + * Get groupNames + * @return groupNames + **/ + @javax.annotation.Nullable + + public List getGroupNames() { + return groupNames; + } + + + public void setGroupNames(List groupNames) { + this.groupNames = groupNames; + } + + + public NotificationMessageCreateRequestDTO messageType(String messageType) { + + this.messageType = messageType; + return this; + } + + /** + * Get messageType + * @return messageType + **/ + @javax.annotation.Nullable + + public String getMessageType() { + return messageType; + } + + + public void setMessageType(String messageType) { + this.messageType = messageType; + } + + + public NotificationMessageCreateRequestDTO subject(String subject) { + + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + **/ + @javax.annotation.Nullable + + public String getSubject() { + return subject; + } + + + public void setSubject(String subject) { + this.subject = subject; + } + + + public NotificationMessageCreateRequestDTO usernames(List usernames) { + + this.usernames = usernames; + return this; + } + + public NotificationMessageCreateRequestDTO addUsernamesItem(String usernamesItem) { + if (this.usernames == null) { + this.usernames = new ArrayList<>(); + } + this.usernames.add(usernamesItem); + return this; + } + + /** + * Get usernames + * @return usernames + **/ + @javax.annotation.Nullable + + public List getUsernames() { + return usernames; + } + + + public void setUsernames(List usernames) { + this.usernames = usernames; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationMessageCreateRequestDTO notificationMessageCreateRequestDTO = (NotificationMessageCreateRequestDTO) o; + return Objects.equals(this.body, notificationMessageCreateRequestDTO.body) && + Objects.equals(this.groupNames, notificationMessageCreateRequestDTO.groupNames) && + Objects.equals(this.messageType, notificationMessageCreateRequestDTO.messageType) && + Objects.equals(this.subject, notificationMessageCreateRequestDTO.subject) && + Objects.equals(this.usernames, notificationMessageCreateRequestDTO.usernames); + } + + @Override + public int hashCode() { + return Objects.hash(body, groupNames, messageType, subject, usernames); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationMessageCreateRequestDTO {\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" groupNames: ").append(toIndentedString(groupNames)).append("\n"); + sb.append(" messageType: ").append(toIndentedString(messageType)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" usernames: ").append(toIndentedString(usernames)).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(); + openapiFields.add("body"); + openapiFields.add("groupNames"); + openapiFields.add("messageType"); + openapiFields.add("subject"); + openapiFields.add("usernames"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NotificationMessageCreateRequestDTO + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NotificationMessageCreateRequestDTO.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NotificationMessageCreateRequestDTO is not found in the empty JSON string", NotificationMessageCreateRequestDTO.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!NotificationMessageCreateRequestDTO.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NotificationMessageCreateRequestDTO` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("body") != null && !jsonObj.get("body").isJsonNull()) && !jsonObj.get("body").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `body` to be a primitive type in the JSON string but got `%s`", jsonObj.get("body").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("groupNames") != null && !jsonObj.get("groupNames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `groupNames` to be an array in the JSON string but got `%s`", jsonObj.get("groupNames").toString())); + } + if ((jsonObj.get("messageType") != null && !jsonObj.get("messageType").isJsonNull()) && !jsonObj.get("messageType").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `messageType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("messageType").toString())); + } + if ((jsonObj.get("subject") != null && !jsonObj.get("subject").isJsonNull()) && !jsonObj.get("subject").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("usernames") != null && !jsonObj.get("usernames").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `usernames` to be an array in the JSON string but got `%s`", jsonObj.get("usernames").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NotificationMessageCreateRequestDTO.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NotificationMessageCreateRequestDTO' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NotificationMessageCreateRequestDTO.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NotificationMessageCreateRequestDTO value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public NotificationMessageCreateRequestDTO read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NotificationMessageCreateRequestDTO given an JSON string + * + * @param jsonString JSON string + * @return An instance of NotificationMessageCreateRequestDTO + * @throws IOException if the JSON string is invalid with respect to NotificationMessageCreateRequestDTO + */ + public static NotificationMessageCreateRequestDTO fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NotificationMessageCreateRequestDTO.class); + } + + /** + * Convert an instance of NotificationMessageCreateRequestDTO to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationRecordResponseDTO.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationRecordResponseDTO.java index 1115524fa..b04487ad8 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationRecordResponseDTO.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/NotificationRecordResponseDTO.java @@ -3,35 +3,49 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.redhat.parodos.notification.sdk.model.Link; import java.io.IOException; import java.util.ArrayList; import java.util.Date; -import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; import java.util.UUID; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -39,493 +53,468 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class NotificationRecordResponseDTO { + public static final String SERIALIZED_NAME_BODY = "body"; + @SerializedName(SERIALIZED_NAME_BODY) + private String body; + + public static final String SERIALIZED_NAME_CREATED_ON = "createdOn"; + @SerializedName(SERIALIZED_NAME_CREATED_ON) + private Date createdOn; + + public static final String SERIALIZED_NAME_FOLDER = "folder"; + @SerializedName(SERIALIZED_NAME_FOLDER) + private String folder; - public static final String SERIALIZED_NAME_BODY = "body"; + public static final String SERIALIZED_NAME_FROMUSER = "fromuser"; + @SerializedName(SERIALIZED_NAME_FROMUSER) + private String fromuser; - @SerializedName(SERIALIZED_NAME_BODY) - private String body; + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + private UUID id; - public static final String SERIALIZED_NAME_CREATED_ON = "createdOn"; + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + private List links = new ArrayList<>(); - @SerializedName(SERIALIZED_NAME_CREATED_ON) - private Date createdOn; + public static final String SERIALIZED_NAME_MESSAGE_TYPE = "messageType"; + @SerializedName(SERIALIZED_NAME_MESSAGE_TYPE) + private String messageType; - public static final String SERIALIZED_NAME_FOLDER = "folder"; + public static final String SERIALIZED_NAME_READ = "read"; + @SerializedName(SERIALIZED_NAME_READ) + private Boolean read; - @SerializedName(SERIALIZED_NAME_FOLDER) - private String folder; + public static final String SERIALIZED_NAME_SUBJECT = "subject"; + @SerializedName(SERIALIZED_NAME_SUBJECT) + private String subject; - public static final String SERIALIZED_NAME_FROMUSER = "fromuser"; + public static final String SERIALIZED_NAME_TAGS = "tags"; + @SerializedName(SERIALIZED_NAME_TAGS) + private List tags = new ArrayList<>(); - @SerializedName(SERIALIZED_NAME_FROMUSER) - private String fromuser; + public NotificationRecordResponseDTO() { + } - public static final String SERIALIZED_NAME_ID = "id"; + public NotificationRecordResponseDTO body(String body) { + + this.body = body; + return this; + } - @SerializedName(SERIALIZED_NAME_ID) - private UUID id; + /** + * Get body + * @return body + **/ + @javax.annotation.Nullable - public static final String SERIALIZED_NAME_LINKS = "links"; + public String getBody() { + return body; + } - @SerializedName(SERIALIZED_NAME_LINKS) - private List links = new ArrayList<>(); - public static final String SERIALIZED_NAME_MESSAGE_TYPE = "messageType"; + public void setBody(String body) { + this.body = body; + } - @SerializedName(SERIALIZED_NAME_MESSAGE_TYPE) - private String messageType; - public static final String SERIALIZED_NAME_READ = "read"; + public NotificationRecordResponseDTO createdOn(Date createdOn) { + + this.createdOn = createdOn; + return this; + } - @SerializedName(SERIALIZED_NAME_READ) - private Boolean read; + /** + * Get createdOn + * @return createdOn + **/ + @javax.annotation.Nullable - public static final String SERIALIZED_NAME_SUBJECT = "subject"; + public Date getCreatedOn() { + return createdOn; + } - @SerializedName(SERIALIZED_NAME_SUBJECT) - private String subject; - public static final String SERIALIZED_NAME_TAGS = "tags"; + public void setCreatedOn(Date createdOn) { + this.createdOn = createdOn; + } - @SerializedName(SERIALIZED_NAME_TAGS) - private List tags = new ArrayList<>(); - public NotificationRecordResponseDTO() { - } + public NotificationRecordResponseDTO folder(String folder) { + + this.folder = folder; + return this; + } - public NotificationRecordResponseDTO body(String body) { + /** + * Get folder + * @return folder + **/ + @javax.annotation.Nullable - this.body = body; - return this; - } + public String getFolder() { + return folder; + } - /** - * Get body - * @return body - **/ - @javax.annotation.Nullable - public String getBody() { - return body; - } + public void setFolder(String folder) { + this.folder = folder; + } - public void setBody(String body) { - this.body = body; - } - public NotificationRecordResponseDTO createdOn(Date createdOn) { + public NotificationRecordResponseDTO fromuser(String fromuser) { + + this.fromuser = fromuser; + return this; + } - this.createdOn = createdOn; - return this; - } + /** + * Get fromuser + * @return fromuser + **/ + @javax.annotation.Nullable - /** - * Get createdOn - * @return createdOn - **/ - @javax.annotation.Nullable + public String getFromuser() { + return fromuser; + } - public Date getCreatedOn() { - return createdOn; - } - public void setCreatedOn(Date createdOn) { - this.createdOn = createdOn; - } + public void setFromuser(String fromuser) { + this.fromuser = fromuser; + } - public NotificationRecordResponseDTO folder(String folder) { - this.folder = folder; - return this; - } + public NotificationRecordResponseDTO id(UUID id) { + + this.id = id; + return this; + } - /** - * Get folder - * @return folder - **/ - @javax.annotation.Nullable + /** + * Get id + * @return id + **/ + @javax.annotation.Nullable - public String getFolder() { - return folder; - } + public UUID getId() { + return id; + } - public void setFolder(String folder) { - this.folder = folder; - } - public NotificationRecordResponseDTO fromuser(String fromuser) { + public void setId(UUID id) { + this.id = id; + } - this.fromuser = fromuser; - return this; - } - /** - * Get fromuser - * @return fromuser - **/ - @javax.annotation.Nullable + public NotificationRecordResponseDTO links(List links) { + + this.links = links; + return this; + } - public String getFromuser() { - return fromuser; - } + public NotificationRecordResponseDTO addLinksItem(Link linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } - public void setFromuser(String fromuser) { - this.fromuser = fromuser; - } + /** + * Get links + * @return links + **/ + @javax.annotation.Nullable - public NotificationRecordResponseDTO id(UUID id) { + public List getLinks() { + return links; + } - this.id = id; - return this; - } - /** - * Get id - * @return id - **/ - @javax.annotation.Nullable + public void setLinks(List links) { + this.links = links; + } - public UUID getId() { - return id; - } - public void setId(UUID id) { - this.id = id; - } - - public NotificationRecordResponseDTO links(List links) { - - this.links = links; - return this; - } - - public NotificationRecordResponseDTO addLinksItem(Link linksItem) { - if (this.links == null) { - this.links = new ArrayList<>(); - } - this.links.add(linksItem); - return this; - } - - /** - * Get links - * @return links - **/ - @javax.annotation.Nullable - - public List getLinks() { - return links; - } - - public void setLinks(List links) { - this.links = links; - } - - public NotificationRecordResponseDTO messageType(String messageType) { - - this.messageType = messageType; - return this; - } - - /** - * Get messageType - * @return messageType - **/ - @javax.annotation.Nullable - - public String getMessageType() { - return messageType; - } - - public void setMessageType(String messageType) { - this.messageType = messageType; - } - - public NotificationRecordResponseDTO read(Boolean read) { - - this.read = read; - return this; - } - - /** - * Get read - * @return read - **/ - @javax.annotation.Nullable - - public Boolean getRead() { - return read; - } - - public void setRead(Boolean read) { - this.read = read; - } - - public NotificationRecordResponseDTO subject(String subject) { - - this.subject = subject; - return this; - } - - /** - * Get subject - * @return subject - **/ - @javax.annotation.Nullable - - public String getSubject() { - return subject; - } - - public void setSubject(String subject) { - this.subject = subject; - } - - public NotificationRecordResponseDTO tags(List tags) { - - this.tags = tags; - return this; - } - - public NotificationRecordResponseDTO addTagsItem(String tagsItem) { - if (this.tags == null) { - this.tags = new ArrayList<>(); - } - this.tags.add(tagsItem); - return this; - } - - /** - * Get tags - * @return tags - **/ - @javax.annotation.Nullable - - public List getTags() { - return tags; - } - - public void setTags(List tags) { - this.tags = tags; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - NotificationRecordResponseDTO notificationRecordResponseDTO = (NotificationRecordResponseDTO) o; - return Objects.equals(this.body, notificationRecordResponseDTO.body) - && Objects.equals(this.createdOn, notificationRecordResponseDTO.createdOn) - && Objects.equals(this.folder, notificationRecordResponseDTO.folder) - && Objects.equals(this.fromuser, notificationRecordResponseDTO.fromuser) - && Objects.equals(this.id, notificationRecordResponseDTO.id) - && Objects.equals(this.links, notificationRecordResponseDTO.links) - && Objects.equals(this.messageType, notificationRecordResponseDTO.messageType) - && Objects.equals(this.read, notificationRecordResponseDTO.read) - && Objects.equals(this.subject, notificationRecordResponseDTO.subject) - && Objects.equals(this.tags, notificationRecordResponseDTO.tags); - } - - @Override - public int hashCode() { - return Objects.hash(body, createdOn, folder, fromuser, id, links, messageType, read, subject, tags); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class NotificationRecordResponseDTO {\n"); - sb.append(" body: ").append(toIndentedString(body)).append("\n"); - sb.append(" createdOn: ").append(toIndentedString(createdOn)).append("\n"); - sb.append(" folder: ").append(toIndentedString(folder)).append("\n"); - sb.append(" fromuser: ").append(toIndentedString(fromuser)).append("\n"); - sb.append(" id: ").append(toIndentedString(id)).append("\n"); - sb.append(" links: ").append(toIndentedString(links)).append("\n"); - sb.append(" messageType: ").append(toIndentedString(messageType)).append("\n"); - sb.append(" read: ").append(toIndentedString(read)).append("\n"); - sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); - sb.append(" tags: ").append(toIndentedString(tags)).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(); - openapiFields.add("body"); - openapiFields.add("createdOn"); - openapiFields.add("folder"); - openapiFields.add("fromuser"); - openapiFields.add("id"); - openapiFields.add("links"); - openapiFields.add("messageType"); - openapiFields.add("read"); - openapiFields.add("subject"); - openapiFields.add("tags"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to - * NotificationRecordResponseDTO - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!NotificationRecordResponseDTO.openapiRequiredFields.isEmpty()) { // has - // required - // fields - // but - // JSON - // object - // is - // null - throw new IllegalArgumentException(String.format( - "The required field(s) %s in NotificationRecordResponseDTO is not found in the empty JSON string", - NotificationRecordResponseDTO.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!NotificationRecordResponseDTO.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `NotificationRecordResponseDTO` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - if ((jsonObj.get("body") != null && !jsonObj.get("body").isJsonNull()) - && !jsonObj.get("body").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `body` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("body").toString())); - } - if ((jsonObj.get("folder") != null && !jsonObj.get("folder").isJsonNull()) - && !jsonObj.get("folder").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `folder` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("folder").toString())); - } - if ((jsonObj.get("fromuser") != null && !jsonObj.get("fromuser").isJsonNull()) - && !jsonObj.get("fromuser").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `fromuser` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("fromuser").toString())); - } - if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("id").toString())); - } - if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) { - JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); - if (jsonArraylinks != null) { - // ensure the json data is an array - if (!jsonObj.get("links").isJsonArray()) { - throw new IllegalArgumentException( - String.format("Expected the field `links` to be an array in the JSON string but got `%s`", - jsonObj.get("links").toString())); - } - - // validate the optional field `links` (array) - for (int i = 0; i < jsonArraylinks.size(); i++) { - Link.validateJsonObject(jsonArraylinks.get(i).getAsJsonObject()); - } - ; - } - } - if ((jsonObj.get("messageType") != null && !jsonObj.get("messageType").isJsonNull()) - && !jsonObj.get("messageType").isJsonPrimitive()) { - throw new IllegalArgumentException(String.format( - "Expected the field `messageType` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("messageType").toString())); - } - if ((jsonObj.get("subject") != null && !jsonObj.get("subject").isJsonNull()) - && !jsonObj.get("subject").isJsonPrimitive()) { - throw new IllegalArgumentException( - String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", - jsonObj.get("subject").toString())); - } - // ensure the optional json data is an array if present - if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonArray()) { - throw new IllegalArgumentException( - String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", - jsonObj.get("tags").toString())); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!NotificationRecordResponseDTO.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'NotificationRecordResponseDTO' - // and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, - TypeToken.get(NotificationRecordResponseDTO.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, NotificationRecordResponseDTO value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public NotificationRecordResponseDTO read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of NotificationRecordResponseDTO given an JSON string - * @param jsonString JSON string - * @return An instance of NotificationRecordResponseDTO - * @throws IOException if the JSON string is invalid with respect to - * NotificationRecordResponseDTO - */ - public static NotificationRecordResponseDTO fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, NotificationRecordResponseDTO.class); - } - - /** - * Convert an instance of NotificationRecordResponseDTO to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } + public NotificationRecordResponseDTO messageType(String messageType) { + + this.messageType = messageType; + return this; + } + /** + * Get messageType + * @return messageType + **/ + @javax.annotation.Nullable + + public String getMessageType() { + return messageType; + } + + + public void setMessageType(String messageType) { + this.messageType = messageType; + } + + + public NotificationRecordResponseDTO read(Boolean read) { + + this.read = read; + return this; + } + + /** + * Get read + * @return read + **/ + @javax.annotation.Nullable + + public Boolean getRead() { + return read; + } + + + public void setRead(Boolean read) { + this.read = read; + } + + + public NotificationRecordResponseDTO subject(String subject) { + + this.subject = subject; + return this; + } + + /** + * Get subject + * @return subject + **/ + @javax.annotation.Nullable + + public String getSubject() { + return subject; + } + + + public void setSubject(String subject) { + this.subject = subject; + } + + + public NotificationRecordResponseDTO tags(List tags) { + + this.tags = tags; + return this; + } + + public NotificationRecordResponseDTO addTagsItem(String tagsItem) { + if (this.tags == null) { + this.tags = new ArrayList<>(); + } + this.tags.add(tagsItem); + return this; + } + + /** + * Get tags + * @return tags + **/ + @javax.annotation.Nullable + + public List getTags() { + return tags; + } + + + public void setTags(List tags) { + this.tags = tags; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + NotificationRecordResponseDTO notificationRecordResponseDTO = (NotificationRecordResponseDTO) o; + return Objects.equals(this.body, notificationRecordResponseDTO.body) && + Objects.equals(this.createdOn, notificationRecordResponseDTO.createdOn) && + Objects.equals(this.folder, notificationRecordResponseDTO.folder) && + Objects.equals(this.fromuser, notificationRecordResponseDTO.fromuser) && + Objects.equals(this.id, notificationRecordResponseDTO.id) && + Objects.equals(this.links, notificationRecordResponseDTO.links) && + Objects.equals(this.messageType, notificationRecordResponseDTO.messageType) && + Objects.equals(this.read, notificationRecordResponseDTO.read) && + Objects.equals(this.subject, notificationRecordResponseDTO.subject) && + Objects.equals(this.tags, notificationRecordResponseDTO.tags); + } + + @Override + public int hashCode() { + return Objects.hash(body, createdOn, folder, fromuser, id, links, messageType, read, subject, tags); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class NotificationRecordResponseDTO {\n"); + sb.append(" body: ").append(toIndentedString(body)).append("\n"); + sb.append(" createdOn: ").append(toIndentedString(createdOn)).append("\n"); + sb.append(" folder: ").append(toIndentedString(folder)).append("\n"); + sb.append(" fromuser: ").append(toIndentedString(fromuser)).append("\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" messageType: ").append(toIndentedString(messageType)).append("\n"); + sb.append(" read: ").append(toIndentedString(read)).append("\n"); + sb.append(" subject: ").append(toIndentedString(subject)).append("\n"); + sb.append(" tags: ").append(toIndentedString(tags)).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(); + openapiFields.add("body"); + openapiFields.add("createdOn"); + openapiFields.add("folder"); + openapiFields.add("fromuser"); + openapiFields.add("id"); + openapiFields.add("links"); + openapiFields.add("messageType"); + openapiFields.add("read"); + openapiFields.add("subject"); + openapiFields.add("tags"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to NotificationRecordResponseDTO + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!NotificationRecordResponseDTO.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in NotificationRecordResponseDTO is not found in the empty JSON string", NotificationRecordResponseDTO.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!NotificationRecordResponseDTO.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `NotificationRecordResponseDTO` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if ((jsonObj.get("body") != null && !jsonObj.get("body").isJsonNull()) && !jsonObj.get("body").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `body` to be a primitive type in the JSON string but got `%s`", jsonObj.get("body").toString())); + } + if ((jsonObj.get("folder") != null && !jsonObj.get("folder").isJsonNull()) && !jsonObj.get("folder").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `folder` to be a primitive type in the JSON string but got `%s`", jsonObj.get("folder").toString())); + } + if ((jsonObj.get("fromuser") != null && !jsonObj.get("fromuser").isJsonNull()) && !jsonObj.get("fromuser").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `fromuser` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fromuser").toString())); + } + if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (jsonObj.get("links") != null && !jsonObj.get("links").isJsonNull()) { + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + if (jsonArraylinks != null) { + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + // validate the optional field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link.validateJsonObject(jsonArraylinks.get(i).getAsJsonObject()); + }; + } + } + if ((jsonObj.get("messageType") != null && !jsonObj.get("messageType").isJsonNull()) && !jsonObj.get("messageType").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `messageType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("messageType").toString())); + } + if ((jsonObj.get("subject") != null && !jsonObj.get("subject").isJsonNull()) && !jsonObj.get("subject").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `subject` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subject").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("tags") != null && !jsonObj.get("tags").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `tags` to be an array in the JSON string but got `%s`", jsonObj.get("tags").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!NotificationRecordResponseDTO.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'NotificationRecordResponseDTO' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(NotificationRecordResponseDTO.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, NotificationRecordResponseDTO value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public NotificationRecordResponseDTO read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of NotificationRecordResponseDTO given an JSON string + * + * @param jsonString JSON string + * @return An instance of NotificationRecordResponseDTO + * @throws IOException if the JSON string is invalid with respect to NotificationRecordResponseDTO + */ + public static NotificationRecordResponseDTO fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, NotificationRecordResponseDTO.class); + } + + /** + * Convert an instance of NotificationRecordResponseDTO to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageNotificationRecordResponseDTO.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageNotificationRecordResponseDTO.java index 24cf553d3..060a83b76 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageNotificationRecordResponseDTO.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageNotificationRecordResponseDTO.java @@ -3,33 +3,49 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; +import java.util.Objects; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.redhat.parodos.notification.sdk.model.NotificationRecordResponseDTO; +import com.redhat.parodos.notification.sdk.model.PageableObject; +import com.redhat.parodos.notification.sdk.model.Sort; import java.io.IOException; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -37,481 +53,475 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PageNotificationRecordResponseDTO { + public static final String SERIALIZED_NAME_CONTENT = "content"; + @SerializedName(SERIALIZED_NAME_CONTENT) + private List content = new ArrayList<>(); + + public static final String SERIALIZED_NAME_EMPTY = "empty"; + @SerializedName(SERIALIZED_NAME_EMPTY) + private Boolean empty; + + public static final String SERIALIZED_NAME_FIRST = "first"; + @SerializedName(SERIALIZED_NAME_FIRST) + private Boolean first; + + public static final String SERIALIZED_NAME_LAST = "last"; + @SerializedName(SERIALIZED_NAME_LAST) + private Boolean last; - public static final String SERIALIZED_NAME_CONTENT = "content"; + public static final String SERIALIZED_NAME_NUMBER = "number"; + @SerializedName(SERIALIZED_NAME_NUMBER) + private Integer number; - @SerializedName(SERIALIZED_NAME_CONTENT) - private List content = new ArrayList<>(); + public static final String SERIALIZED_NAME_NUMBER_OF_ELEMENTS = "numberOfElements"; + @SerializedName(SERIALIZED_NAME_NUMBER_OF_ELEMENTS) + private Integer numberOfElements; - public static final String SERIALIZED_NAME_EMPTY = "empty"; + public static final String SERIALIZED_NAME_PAGEABLE = "pageable"; + @SerializedName(SERIALIZED_NAME_PAGEABLE) + private PageableObject pageable; - @SerializedName(SERIALIZED_NAME_EMPTY) - private Boolean empty; + public static final String SERIALIZED_NAME_SIZE = "size"; + @SerializedName(SERIALIZED_NAME_SIZE) + private Integer size; + + public static final String SERIALIZED_NAME_SORT = "sort"; + @SerializedName(SERIALIZED_NAME_SORT) + private Sort sort; + + public static final String SERIALIZED_NAME_TOTAL_ELEMENTS = "totalElements"; + @SerializedName(SERIALIZED_NAME_TOTAL_ELEMENTS) + private Long totalElements; - public static final String SERIALIZED_NAME_FIRST = "first"; + public static final String SERIALIZED_NAME_TOTAL_PAGES = "totalPages"; + @SerializedName(SERIALIZED_NAME_TOTAL_PAGES) + private Integer totalPages; - @SerializedName(SERIALIZED_NAME_FIRST) - private Boolean first; + public PageNotificationRecordResponseDTO() { + } - public static final String SERIALIZED_NAME_LAST = "last"; + public PageNotificationRecordResponseDTO content(List content) { + + this.content = content; + return this; + } - @SerializedName(SERIALIZED_NAME_LAST) - private Boolean last; + public PageNotificationRecordResponseDTO addContentItem(NotificationRecordResponseDTO contentItem) { + if (this.content == null) { + this.content = new ArrayList<>(); + } + this.content.add(contentItem); + return this; + } - public static final String SERIALIZED_NAME_NUMBER = "number"; + /** + * Get content + * @return content + **/ + @javax.annotation.Nullable - @SerializedName(SERIALIZED_NAME_NUMBER) - private Integer number; + public List getContent() { + return content; + } - public static final String SERIALIZED_NAME_NUMBER_OF_ELEMENTS = "numberOfElements"; - @SerializedName(SERIALIZED_NAME_NUMBER_OF_ELEMENTS) - private Integer numberOfElements; + public void setContent(List content) { + this.content = content; + } - public static final String SERIALIZED_NAME_PAGEABLE = "pageable"; - @SerializedName(SERIALIZED_NAME_PAGEABLE) - private PageableObject pageable; + public PageNotificationRecordResponseDTO empty(Boolean empty) { + + this.empty = empty; + return this; + } - public static final String SERIALIZED_NAME_SIZE = "size"; + /** + * Get empty + * @return empty + **/ + @javax.annotation.Nullable - @SerializedName(SERIALIZED_NAME_SIZE) - private Integer size; + public Boolean getEmpty() { + return empty; + } - public static final String SERIALIZED_NAME_SORT = "sort"; - @SerializedName(SERIALIZED_NAME_SORT) - private Sort sort; + public void setEmpty(Boolean empty) { + this.empty = empty; + } - public static final String SERIALIZED_NAME_TOTAL_ELEMENTS = "totalElements"; - @SerializedName(SERIALIZED_NAME_TOTAL_ELEMENTS) - private Long totalElements; + public PageNotificationRecordResponseDTO first(Boolean first) { + + this.first = first; + return this; + } - public static final String SERIALIZED_NAME_TOTAL_PAGES = "totalPages"; + /** + * Get first + * @return first + **/ + @javax.annotation.Nullable - @SerializedName(SERIALIZED_NAME_TOTAL_PAGES) - private Integer totalPages; + public Boolean getFirst() { + return first; + } - public PageNotificationRecordResponseDTO() { - } - public PageNotificationRecordResponseDTO content(List content) { + public void setFirst(Boolean first) { + this.first = first; + } - this.content = content; - return this; - } - public PageNotificationRecordResponseDTO addContentItem(NotificationRecordResponseDTO contentItem) { - if (this.content == null) { - this.content = new ArrayList<>(); - } - this.content.add(contentItem); - return this; - } + public PageNotificationRecordResponseDTO last(Boolean last) { + + this.last = last; + return this; + } - /** - * Get content - * @return content - **/ - @javax.annotation.Nullable + /** + * Get last + * @return last + **/ + @javax.annotation.Nullable - public List getContent() { - return content; - } + public Boolean getLast() { + return last; + } - public void setContent(List content) { - this.content = content; - } - public PageNotificationRecordResponseDTO empty(Boolean empty) { + public void setLast(Boolean last) { + this.last = last; + } - this.empty = empty; - return this; - } - /** - * Get empty - * @return empty - **/ - @javax.annotation.Nullable + public PageNotificationRecordResponseDTO number(Integer number) { + + this.number = number; + return this; + } - public Boolean getEmpty() { - return empty; - } + /** + * Get number + * @return number + **/ + @javax.annotation.Nullable - public void setEmpty(Boolean empty) { - this.empty = empty; - } + public Integer getNumber() { + return number; + } - public PageNotificationRecordResponseDTO first(Boolean first) { - this.first = first; - return this; - } + public void setNumber(Integer number) { + this.number = number; + } - /** - * Get first - * @return first - **/ - @javax.annotation.Nullable - public Boolean getFirst() { - return first; - } + public PageNotificationRecordResponseDTO numberOfElements(Integer numberOfElements) { + + this.numberOfElements = numberOfElements; + return this; + } - public void setFirst(Boolean first) { - this.first = first; - } + /** + * Get numberOfElements + * @return numberOfElements + **/ + @javax.annotation.Nullable - public PageNotificationRecordResponseDTO last(Boolean last) { + public Integer getNumberOfElements() { + return numberOfElements; + } - this.last = last; - return this; - } - /** - * Get last - * @return last - **/ - @javax.annotation.Nullable + public void setNumberOfElements(Integer numberOfElements) { + this.numberOfElements = numberOfElements; + } - public Boolean getLast() { - return last; - } - public void setLast(Boolean last) { - this.last = last; - } + public PageNotificationRecordResponseDTO pageable(PageableObject pageable) { + + this.pageable = pageable; + return this; + } - public PageNotificationRecordResponseDTO number(Integer number) { + /** + * Get pageable + * @return pageable + **/ + @javax.annotation.Nullable - this.number = number; - return this; - } + public PageableObject getPageable() { + return pageable; + } - /** - * Get number - * @return number - **/ - @javax.annotation.Nullable - public Integer getNumber() { - return number; - } - - public void setNumber(Integer number) { - this.number = number; - } - - public PageNotificationRecordResponseDTO numberOfElements(Integer numberOfElements) { + public void setPageable(PageableObject pageable) { + this.pageable = pageable; + } - this.numberOfElements = numberOfElements; - return this; - } - /** - * Get numberOfElements - * @return numberOfElements - **/ - @javax.annotation.Nullable + public PageNotificationRecordResponseDTO size(Integer size) { + + this.size = size; + return this; + } - public Integer getNumberOfElements() { - return numberOfElements; - } + /** + * Get size + * @return size + **/ + @javax.annotation.Nullable - public void setNumberOfElements(Integer numberOfElements) { - this.numberOfElements = numberOfElements; - } + public Integer getSize() { + return size; + } - public PageNotificationRecordResponseDTO pageable(PageableObject pageable) { - this.pageable = pageable; - return this; - } - - /** - * Get pageable - * @return pageable - **/ - @javax.annotation.Nullable - - public PageableObject getPageable() { - return pageable; - } - - public void setPageable(PageableObject pageable) { - this.pageable = pageable; - } - - public PageNotificationRecordResponseDTO size(Integer size) { - - this.size = size; - return this; - } - - /** - * Get size - * @return size - **/ - @javax.annotation.Nullable - - public Integer getSize() { - return size; - } - - public void setSize(Integer size) { - this.size = size; - } - - public PageNotificationRecordResponseDTO sort(Sort sort) { - - this.sort = sort; - return this; - } - - /** - * Get sort - * @return sort - **/ - @javax.annotation.Nullable - - public Sort getSort() { - return sort; - } - - public void setSort(Sort sort) { - this.sort = sort; - } - - public PageNotificationRecordResponseDTO totalElements(Long totalElements) { - - this.totalElements = totalElements; - return this; - } - - /** - * Get totalElements - * @return totalElements - **/ - @javax.annotation.Nullable - - public Long getTotalElements() { - return totalElements; - } - - public void setTotalElements(Long totalElements) { - this.totalElements = totalElements; - } - - public PageNotificationRecordResponseDTO totalPages(Integer totalPages) { - - this.totalPages = totalPages; - return this; - } - - /** - * Get totalPages - * @return totalPages - **/ - @javax.annotation.Nullable - - public Integer getTotalPages() { - return totalPages; - } - - public void setTotalPages(Integer totalPages) { - this.totalPages = totalPages; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PageNotificationRecordResponseDTO pageNotificationRecordResponseDTO = (PageNotificationRecordResponseDTO) o; - return Objects.equals(this.content, pageNotificationRecordResponseDTO.content) - && Objects.equals(this.empty, pageNotificationRecordResponseDTO.empty) - && Objects.equals(this.first, pageNotificationRecordResponseDTO.first) - && Objects.equals(this.last, pageNotificationRecordResponseDTO.last) - && Objects.equals(this.number, pageNotificationRecordResponseDTO.number) - && Objects.equals(this.numberOfElements, pageNotificationRecordResponseDTO.numberOfElements) - && Objects.equals(this.pageable, pageNotificationRecordResponseDTO.pageable) - && Objects.equals(this.size, pageNotificationRecordResponseDTO.size) - && Objects.equals(this.sort, pageNotificationRecordResponseDTO.sort) - && Objects.equals(this.totalElements, pageNotificationRecordResponseDTO.totalElements) - && Objects.equals(this.totalPages, pageNotificationRecordResponseDTO.totalPages); - } - - @Override - public int hashCode() { - return Objects.hash(content, empty, first, last, number, numberOfElements, pageable, size, sort, totalElements, - totalPages); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PageNotificationRecordResponseDTO {\n"); - sb.append(" content: ").append(toIndentedString(content)).append("\n"); - sb.append(" empty: ").append(toIndentedString(empty)).append("\n"); - sb.append(" first: ").append(toIndentedString(first)).append("\n"); - sb.append(" last: ").append(toIndentedString(last)).append("\n"); - sb.append(" number: ").append(toIndentedString(number)).append("\n"); - sb.append(" numberOfElements: ").append(toIndentedString(numberOfElements)).append("\n"); - sb.append(" pageable: ").append(toIndentedString(pageable)).append("\n"); - sb.append(" size: ").append(toIndentedString(size)).append("\n"); - sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); - sb.append(" totalElements: ").append(toIndentedString(totalElements)).append("\n"); - sb.append(" totalPages: ").append(toIndentedString(totalPages)).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(); - openapiFields.add("content"); - openapiFields.add("empty"); - openapiFields.add("first"); - openapiFields.add("last"); - openapiFields.add("number"); - openapiFields.add("numberOfElements"); - openapiFields.add("pageable"); - openapiFields.add("size"); - openapiFields.add("sort"); - openapiFields.add("totalElements"); - openapiFields.add("totalPages"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to - * PageNotificationRecordResponseDTO - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!PageNotificationRecordResponseDTO.openapiRequiredFields.isEmpty()) { // has - // required - // fields - // but - // JSON - // object - // is - // null - throw new IllegalArgumentException(String.format( - "The required field(s) %s in PageNotificationRecordResponseDTO is not found in the empty JSON string", - PageNotificationRecordResponseDTO.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!PageNotificationRecordResponseDTO.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `PageNotificationRecordResponseDTO` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - if (jsonObj.get("content") != null && !jsonObj.get("content").isJsonNull()) { - JsonArray jsonArraycontent = jsonObj.getAsJsonArray("content"); - if (jsonArraycontent != null) { - // ensure the json data is an array - if (!jsonObj.get("content").isJsonArray()) { - throw new IllegalArgumentException( - String.format("Expected the field `content` to be an array in the JSON string but got `%s`", - jsonObj.get("content").toString())); - } - - // validate the optional field `content` (array) - for (int i = 0; i < jsonArraycontent.size(); i++) { - NotificationRecordResponseDTO.validateJsonObject(jsonArraycontent.get(i).getAsJsonObject()); - } - ; - } - } - // validate the optional field `pageable` - if (jsonObj.get("pageable") != null && !jsonObj.get("pageable").isJsonNull()) { - PageableObject.validateJsonObject(jsonObj.getAsJsonObject("pageable")); - } - // validate the optional field `sort` - if (jsonObj.get("sort") != null && !jsonObj.get("sort").isJsonNull()) { - Sort.validateJsonObject(jsonObj.getAsJsonObject("sort")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!PageNotificationRecordResponseDTO.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes - // 'PageNotificationRecordResponseDTO' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, - TypeToken.get(PageNotificationRecordResponseDTO.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, PageNotificationRecordResponseDTO value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public PageNotificationRecordResponseDTO read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of PageNotificationRecordResponseDTO given an JSON string - * @param jsonString JSON string - * @return An instance of PageNotificationRecordResponseDTO - * @throws IOException if the JSON string is invalid with respect to - * PageNotificationRecordResponseDTO - */ - public static PageNotificationRecordResponseDTO fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PageNotificationRecordResponseDTO.class); - } - - /** - * Convert an instance of PageNotificationRecordResponseDTO to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } + public void setSize(Integer size) { + this.size = size; + } + + public PageNotificationRecordResponseDTO sort(Sort sort) { + + this.sort = sort; + return this; + } + + /** + * Get sort + * @return sort + **/ + @javax.annotation.Nullable + + public Sort getSort() { + return sort; + } + + + public void setSort(Sort sort) { + this.sort = sort; + } + + + public PageNotificationRecordResponseDTO totalElements(Long totalElements) { + + this.totalElements = totalElements; + return this; + } + + /** + * Get totalElements + * @return totalElements + **/ + @javax.annotation.Nullable + + public Long getTotalElements() { + return totalElements; + } + + + public void setTotalElements(Long totalElements) { + this.totalElements = totalElements; + } + + + public PageNotificationRecordResponseDTO totalPages(Integer totalPages) { + + this.totalPages = totalPages; + return this; + } + + /** + * Get totalPages + * @return totalPages + **/ + @javax.annotation.Nullable + + public Integer getTotalPages() { + return totalPages; + } + + + public void setTotalPages(Integer totalPages) { + this.totalPages = totalPages; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PageNotificationRecordResponseDTO pageNotificationRecordResponseDTO = (PageNotificationRecordResponseDTO) o; + return Objects.equals(this.content, pageNotificationRecordResponseDTO.content) && + Objects.equals(this.empty, pageNotificationRecordResponseDTO.empty) && + Objects.equals(this.first, pageNotificationRecordResponseDTO.first) && + Objects.equals(this.last, pageNotificationRecordResponseDTO.last) && + Objects.equals(this.number, pageNotificationRecordResponseDTO.number) && + Objects.equals(this.numberOfElements, pageNotificationRecordResponseDTO.numberOfElements) && + Objects.equals(this.pageable, pageNotificationRecordResponseDTO.pageable) && + Objects.equals(this.size, pageNotificationRecordResponseDTO.size) && + Objects.equals(this.sort, pageNotificationRecordResponseDTO.sort) && + Objects.equals(this.totalElements, pageNotificationRecordResponseDTO.totalElements) && + Objects.equals(this.totalPages, pageNotificationRecordResponseDTO.totalPages); + } + + @Override + public int hashCode() { + return Objects.hash(content, empty, first, last, number, numberOfElements, pageable, size, sort, totalElements, totalPages); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PageNotificationRecordResponseDTO {\n"); + sb.append(" content: ").append(toIndentedString(content)).append("\n"); + sb.append(" empty: ").append(toIndentedString(empty)).append("\n"); + sb.append(" first: ").append(toIndentedString(first)).append("\n"); + sb.append(" last: ").append(toIndentedString(last)).append("\n"); + sb.append(" number: ").append(toIndentedString(number)).append("\n"); + sb.append(" numberOfElements: ").append(toIndentedString(numberOfElements)).append("\n"); + sb.append(" pageable: ").append(toIndentedString(pageable)).append("\n"); + sb.append(" size: ").append(toIndentedString(size)).append("\n"); + sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append(" totalElements: ").append(toIndentedString(totalElements)).append("\n"); + sb.append(" totalPages: ").append(toIndentedString(totalPages)).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(); + openapiFields.add("content"); + openapiFields.add("empty"); + openapiFields.add("first"); + openapiFields.add("last"); + openapiFields.add("number"); + openapiFields.add("numberOfElements"); + openapiFields.add("pageable"); + openapiFields.add("size"); + openapiFields.add("sort"); + openapiFields.add("totalElements"); + openapiFields.add("totalPages"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PageNotificationRecordResponseDTO + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PageNotificationRecordResponseDTO.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PageNotificationRecordResponseDTO is not found in the empty JSON string", PageNotificationRecordResponseDTO.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PageNotificationRecordResponseDTO.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PageNotificationRecordResponseDTO` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + if (jsonObj.get("content") != null && !jsonObj.get("content").isJsonNull()) { + JsonArray jsonArraycontent = jsonObj.getAsJsonArray("content"); + if (jsonArraycontent != null) { + // ensure the json data is an array + if (!jsonObj.get("content").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `content` to be an array in the JSON string but got `%s`", jsonObj.get("content").toString())); + } + + // validate the optional field `content` (array) + for (int i = 0; i < jsonArraycontent.size(); i++) { + NotificationRecordResponseDTO.validateJsonObject(jsonArraycontent.get(i).getAsJsonObject()); + }; + } + } + // validate the optional field `pageable` + if (jsonObj.get("pageable") != null && !jsonObj.get("pageable").isJsonNull()) { + PageableObject.validateJsonObject(jsonObj.getAsJsonObject("pageable")); + } + // validate the optional field `sort` + if (jsonObj.get("sort") != null && !jsonObj.get("sort").isJsonNull()) { + Sort.validateJsonObject(jsonObj.getAsJsonObject("sort")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PageNotificationRecordResponseDTO.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PageNotificationRecordResponseDTO' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PageNotificationRecordResponseDTO.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PageNotificationRecordResponseDTO value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PageNotificationRecordResponseDTO read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PageNotificationRecordResponseDTO given an JSON string + * + * @param jsonString JSON string + * @return An instance of PageNotificationRecordResponseDTO + * @throws IOException if the JSON string is invalid with respect to PageNotificationRecordResponseDTO + */ + public static PageNotificationRecordResponseDTO fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PageNotificationRecordResponseDTO.class); + } + + /** + * Convert an instance of PageNotificationRecordResponseDTO to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageableObject.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageableObject.java index 1d5896202..15f131fd7 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageableObject.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/PageableObject.java @@ -3,30 +3,45 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; -import java.io.IOException; -import java.util.HashSet; -import java.util.Map.Entry; import java.util.Objects; -import java.util.Set; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.redhat.parodos.notification.sdk.model.Sort; +import java.io.IOException; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -34,303 +49,304 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class PageableObject { + public static final String SERIALIZED_NAME_OFFSET = "offset"; + @SerializedName(SERIALIZED_NAME_OFFSET) + private Long offset; - public static final String SERIALIZED_NAME_OFFSET = "offset"; - - @SerializedName(SERIALIZED_NAME_OFFSET) - private Long offset; + public static final String SERIALIZED_NAME_PAGE_NUMBER = "pageNumber"; + @SerializedName(SERIALIZED_NAME_PAGE_NUMBER) + private Integer pageNumber; - public static final String SERIALIZED_NAME_PAGE_NUMBER = "pageNumber"; + public static final String SERIALIZED_NAME_PAGE_SIZE = "pageSize"; + @SerializedName(SERIALIZED_NAME_PAGE_SIZE) + private Integer pageSize; - @SerializedName(SERIALIZED_NAME_PAGE_NUMBER) - private Integer pageNumber; + public static final String SERIALIZED_NAME_PAGED = "paged"; + @SerializedName(SERIALIZED_NAME_PAGED) + private Boolean paged; - public static final String SERIALIZED_NAME_PAGE_SIZE = "pageSize"; + public static final String SERIALIZED_NAME_SORT = "sort"; + @SerializedName(SERIALIZED_NAME_SORT) + private Sort sort; - @SerializedName(SERIALIZED_NAME_PAGE_SIZE) - private Integer pageSize; + public static final String SERIALIZED_NAME_UNPAGED = "unpaged"; + @SerializedName(SERIALIZED_NAME_UNPAGED) + private Boolean unpaged; - public static final String SERIALIZED_NAME_PAGED = "paged"; + public PageableObject() { + } - @SerializedName(SERIALIZED_NAME_PAGED) - private Boolean paged; + public PageableObject offset(Long offset) { + + this.offset = offset; + return this; + } - public static final String SERIALIZED_NAME_SORT = "sort"; + /** + * Get offset + * @return offset + **/ + @javax.annotation.Nullable - @SerializedName(SERIALIZED_NAME_SORT) - private Sort sort; + public Long getOffset() { + return offset; + } - public static final String SERIALIZED_NAME_UNPAGED = "unpaged"; - @SerializedName(SERIALIZED_NAME_UNPAGED) - private Boolean unpaged; + public void setOffset(Long offset) { + this.offset = offset; + } - public PageableObject() { - } - public PageableObject offset(Long offset) { + public PageableObject pageNumber(Integer pageNumber) { + + this.pageNumber = pageNumber; + return this; + } - this.offset = offset; - return this; - } + /** + * Get pageNumber + * @return pageNumber + **/ + @javax.annotation.Nullable - /** - * Get offset - * @return offset - **/ - @javax.annotation.Nullable + public Integer getPageNumber() { + return pageNumber; + } - public Long getOffset() { - return offset; - } - public void setOffset(Long offset) { - this.offset = offset; - } + public void setPageNumber(Integer pageNumber) { + this.pageNumber = pageNumber; + } - public PageableObject pageNumber(Integer pageNumber) { - this.pageNumber = pageNumber; - return this; - } + public PageableObject pageSize(Integer pageSize) { + + this.pageSize = pageSize; + return this; + } - /** - * Get pageNumber - * @return pageNumber - **/ - @javax.annotation.Nullable + /** + * Get pageSize + * @return pageSize + **/ + @javax.annotation.Nullable - public Integer getPageNumber() { - return pageNumber; - } - - public void setPageNumber(Integer pageNumber) { - this.pageNumber = pageNumber; - } - - public PageableObject pageSize(Integer pageSize) { - - this.pageSize = pageSize; - return this; - } - - /** - * Get pageSize - * @return pageSize - **/ - @javax.annotation.Nullable - - public Integer getPageSize() { - return pageSize; - } - - public void setPageSize(Integer pageSize) { - this.pageSize = pageSize; - } - - public PageableObject paged(Boolean paged) { - - this.paged = paged; - return this; - } - - /** - * Get paged - * @return paged - **/ - @javax.annotation.Nullable - - public Boolean getPaged() { - return paged; - } - - public void setPaged(Boolean paged) { - this.paged = paged; - } - - public PageableObject sort(Sort sort) { - - this.sort = sort; - return this; - } - - /** - * Get sort - * @return sort - **/ - @javax.annotation.Nullable - - public Sort getSort() { - return sort; - } - - public void setSort(Sort sort) { - this.sort = sort; - } - - public PageableObject unpaged(Boolean unpaged) { - - this.unpaged = unpaged; - return this; - } - - /** - * Get unpaged - * @return unpaged - **/ - @javax.annotation.Nullable - - public Boolean getUnpaged() { - return unpaged; - } - - public void setUnpaged(Boolean unpaged) { - this.unpaged = unpaged; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - PageableObject pageableObject = (PageableObject) o; - return Objects.equals(this.offset, pageableObject.offset) - && Objects.equals(this.pageNumber, pageableObject.pageNumber) - && Objects.equals(this.pageSize, pageableObject.pageSize) - && Objects.equals(this.paged, pageableObject.paged) && Objects.equals(this.sort, pageableObject.sort) - && Objects.equals(this.unpaged, pageableObject.unpaged); - } - - @Override - public int hashCode() { - return Objects.hash(offset, pageNumber, pageSize, paged, sort, unpaged); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class PageableObject {\n"); - sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); - sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); - sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); - sb.append(" paged: ").append(toIndentedString(paged)).append("\n"); - sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); - sb.append(" unpaged: ").append(toIndentedString(unpaged)).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(); - openapiFields.add("offset"); - openapiFields.add("pageNumber"); - openapiFields.add("pageSize"); - openapiFields.add("paged"); - openapiFields.add("sort"); - openapiFields.add("unpaged"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to PageableObject - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!PageableObject.openapiRequiredFields.isEmpty()) { // has required fields - // but JSON object is - // null - throw new IllegalArgumentException(String.format( - "The required field(s) %s in PageableObject is not found in the empty JSON string", - PageableObject.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!PageableObject.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `PageableObject` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - // validate the optional field `sort` - if (jsonObj.get("sort") != null && !jsonObj.get("sort").isJsonNull()) { - Sort.validateJsonObject(jsonObj.getAsJsonObject("sort")); - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!PageableObject.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'PageableObject' and its - // subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, - TypeToken.get(PageableObject.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, PageableObject value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public PageableObject read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of PageableObject given an JSON string - * @param jsonString JSON string - * @return An instance of PageableObject - * @throws IOException if the JSON string is invalid with respect to PageableObject - */ - public static PageableObject fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, PageableObject.class); - } - - /** - * Convert an instance of PageableObject to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + + public PageableObject paged(Boolean paged) { + + this.paged = paged; + return this; + } + + /** + * Get paged + * @return paged + **/ + @javax.annotation.Nullable + + public Boolean getPaged() { + return paged; + } + + + public void setPaged(Boolean paged) { + this.paged = paged; + } + + + public PageableObject sort(Sort sort) { + + this.sort = sort; + return this; + } + + /** + * Get sort + * @return sort + **/ + @javax.annotation.Nullable + + public Sort getSort() { + return sort; + } + + + public void setSort(Sort sort) { + this.sort = sort; + } + + + public PageableObject unpaged(Boolean unpaged) { + + this.unpaged = unpaged; + return this; + } + + /** + * Get unpaged + * @return unpaged + **/ + @javax.annotation.Nullable + + public Boolean getUnpaged() { + return unpaged; + } + + + public void setUnpaged(Boolean unpaged) { + this.unpaged = unpaged; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PageableObject pageableObject = (PageableObject) o; + return Objects.equals(this.offset, pageableObject.offset) && + Objects.equals(this.pageNumber, pageableObject.pageNumber) && + Objects.equals(this.pageSize, pageableObject.pageSize) && + Objects.equals(this.paged, pageableObject.paged) && + Objects.equals(this.sort, pageableObject.sort) && + Objects.equals(this.unpaged, pageableObject.unpaged); + } + + @Override + public int hashCode() { + return Objects.hash(offset, pageNumber, pageSize, paged, sort, unpaged); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class PageableObject {\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" paged: ").append(toIndentedString(paged)).append("\n"); + sb.append(" sort: ").append(toIndentedString(sort)).append("\n"); + sb.append(" unpaged: ").append(toIndentedString(unpaged)).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(); + openapiFields.add("offset"); + openapiFields.add("pageNumber"); + openapiFields.add("pageSize"); + openapiFields.add("paged"); + openapiFields.add("sort"); + openapiFields.add("unpaged"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to PageableObject + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!PageableObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in PageableObject is not found in the empty JSON string", PageableObject.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!PageableObject.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `PageableObject` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + // validate the optional field `sort` + if (jsonObj.get("sort") != null && !jsonObj.get("sort").isJsonNull()) { + Sort.validateJsonObject(jsonObj.getAsJsonObject("sort")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!PageableObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'PageableObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(PageableObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, PageableObject value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public PageableObject read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of PageableObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of PageableObject + * @throws IOException if the JSON string is invalid with respect to PageableObject + */ + public static PageableObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, PageableObject.class); + } + + /** + * Convert an instance of PageableObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Sort.java b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Sort.java index c97a8d705..5b44488a2 100644 --- a/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Sort.java +++ b/notification-service-sdk/src/main/java/com/redhat/parodos/notification/sdk/model/Sort.java @@ -3,30 +3,44 @@ * This is the API documentation for the Parodos Notification Service. It provides operations to send out and check notification. The endpoints are secured with oAuth2/OpenID and cannot be accessed without a valid token. * * The version of the OpenAPI document: v1.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 com.redhat.parodos.notification.sdk.model; -import java.io.IOException; -import java.util.HashSet; -import java.util.Map.Entry; import java.util.Objects; -import java.util.Set; +import java.util.Arrays; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import com.google.gson.TypeAdapter; +import com.google.gson.JsonParseException; 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.lang.reflect.Type; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import com.redhat.parodos.notification.sdk.api.JSON; /** @@ -34,212 +48,213 @@ */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen") public class Sort { - - public static final String SERIALIZED_NAME_EMPTY = "empty"; - - @SerializedName(SERIALIZED_NAME_EMPTY) - private Boolean empty; - - public static final String SERIALIZED_NAME_SORTED = "sorted"; - - @SerializedName(SERIALIZED_NAME_SORTED) - private Boolean sorted; - - public static final String SERIALIZED_NAME_UNSORTED = "unsorted"; - - @SerializedName(SERIALIZED_NAME_UNSORTED) - private Boolean unsorted; - - public Sort() { - } - - public Sort empty(Boolean empty) { - - this.empty = empty; - return this; - } - - /** - * Get empty - * @return empty - **/ - @javax.annotation.Nullable - - public Boolean getEmpty() { - return empty; - } - - public void setEmpty(Boolean empty) { - this.empty = empty; - } - - public Sort sorted(Boolean sorted) { - - this.sorted = sorted; - return this; - } - - /** - * Get sorted - * @return sorted - **/ - @javax.annotation.Nullable - - public Boolean getSorted() { - return sorted; - } - - public void setSorted(Boolean sorted) { - this.sorted = sorted; - } - - public Sort unsorted(Boolean unsorted) { - - this.unsorted = unsorted; - return this; - } - - /** - * Get unsorted - * @return unsorted - **/ - @javax.annotation.Nullable - - public Boolean getUnsorted() { - return unsorted; - } - - public void setUnsorted(Boolean unsorted) { - this.unsorted = unsorted; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - Sort sort = (Sort) o; - return Objects.equals(this.empty, sort.empty) && Objects.equals(this.sorted, sort.sorted) - && Objects.equals(this.unsorted, sort.unsorted); - } - - @Override - public int hashCode() { - return Objects.hash(empty, sorted, unsorted); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("class Sort {\n"); - sb.append(" empty: ").append(toIndentedString(empty)).append("\n"); - sb.append(" sorted: ").append(toIndentedString(sorted)).append("\n"); - sb.append(" unsorted: ").append(toIndentedString(unsorted)).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(); - openapiFields.add("empty"); - openapiFields.add("sorted"); - openapiFields.add("unsorted"); - - // a set of required properties/fields (JSON key names) - openapiRequiredFields = new HashSet(); - } - - /** - * Validates the JSON Object and throws an exception if issues found - * @param jsonObj JSON Object - * @throws IOException if the JSON Object is invalid with respect to Sort - */ - public static void validateJsonObject(JsonObject jsonObj) throws IOException { - if (jsonObj == null) { - if (!Sort.openapiRequiredFields.isEmpty()) { // has required fields but JSON - // object is null - throw new IllegalArgumentException( - String.format("The required field(s) %s in Sort is not found in the empty JSON string", - Sort.openapiRequiredFields.toString())); - } - } - - Set> entries = jsonObj.entrySet(); - // check to see if the JSON string contains additional fields - for (Entry entry : entries) { - if (!Sort.openapiFields.contains(entry.getKey())) { - throw new IllegalArgumentException(String.format( - "The field `%s` in the JSON string is not defined in the `Sort` properties. JSON: %s", - entry.getKey(), jsonObj.toString())); - } - } - } - - public static class CustomTypeAdapterFactory implements TypeAdapterFactory { - - @SuppressWarnings("unchecked") - @Override - public TypeAdapter create(Gson gson, TypeToken type) { - if (!Sort.class.isAssignableFrom(type.getRawType())) { - return null; // this class only serializes 'Sort' and its subtypes - } - final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); - final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(Sort.class)); - - return (TypeAdapter) new TypeAdapter() { - @Override - public void write(JsonWriter out, Sort value) throws IOException { - JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); - elementAdapter.write(out, obj); - } - - @Override - public Sort read(JsonReader in) throws IOException { - JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); - validateJsonObject(jsonObj); - return thisAdapter.fromJsonTree(jsonObj); - } - - }.nullSafe(); - } - - } - - /** - * Create an instance of Sort given an JSON string - * @param jsonString JSON string - * @return An instance of Sort - * @throws IOException if the JSON string is invalid with respect to Sort - */ - public static Sort fromJson(String jsonString) throws IOException { - return JSON.getGson().fromJson(jsonString, Sort.class); - } - - /** - * Convert an instance of Sort to an JSON string - * @return JSON string - */ - public String toJson() { - return JSON.getGson().toJson(this); - } - + public static final String SERIALIZED_NAME_EMPTY = "empty"; + @SerializedName(SERIALIZED_NAME_EMPTY) + private Boolean empty; + + public static final String SERIALIZED_NAME_SORTED = "sorted"; + @SerializedName(SERIALIZED_NAME_SORTED) + private Boolean sorted; + + public static final String SERIALIZED_NAME_UNSORTED = "unsorted"; + @SerializedName(SERIALIZED_NAME_UNSORTED) + private Boolean unsorted; + + public Sort() { + } + + public Sort empty(Boolean empty) { + + this.empty = empty; + return this; + } + + /** + * Get empty + * @return empty + **/ + @javax.annotation.Nullable + + public Boolean getEmpty() { + return empty; + } + + + public void setEmpty(Boolean empty) { + this.empty = empty; + } + + + public Sort sorted(Boolean sorted) { + + this.sorted = sorted; + return this; + } + + /** + * Get sorted + * @return sorted + **/ + @javax.annotation.Nullable + + public Boolean getSorted() { + return sorted; + } + + + public void setSorted(Boolean sorted) { + this.sorted = sorted; + } + + + public Sort unsorted(Boolean unsorted) { + + this.unsorted = unsorted; + return this; + } + + /** + * Get unsorted + * @return unsorted + **/ + @javax.annotation.Nullable + + public Boolean getUnsorted() { + return unsorted; + } + + + public void setUnsorted(Boolean unsorted) { + this.unsorted = unsorted; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Sort sort = (Sort) o; + return Objects.equals(this.empty, sort.empty) && + Objects.equals(this.sorted, sort.sorted) && + Objects.equals(this.unsorted, sort.unsorted); + } + + @Override + public int hashCode() { + return Objects.hash(empty, sorted, unsorted); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Sort {\n"); + sb.append(" empty: ").append(toIndentedString(empty)).append("\n"); + sb.append(" sorted: ").append(toIndentedString(sorted)).append("\n"); + sb.append(" unsorted: ").append(toIndentedString(unsorted)).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(); + openapiFields.add("empty"); + openapiFields.add("sorted"); + openapiFields.add("unsorted"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * Validates the JSON Object and throws an exception if issues found + * + * @param jsonObj JSON Object + * @throws IOException if the JSON Object is invalid with respect to Sort + */ + public static void validateJsonObject(JsonObject jsonObj) throws IOException { + if (jsonObj == null) { + if (!Sort.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null + throw new IllegalArgumentException(String.format("The required field(s) %s in Sort is not found in the empty JSON string", Sort.openapiRequiredFields.toString())); + } + } + + Set> entries = jsonObj.entrySet(); + // check to see if the JSON string contains additional fields + for (Entry entry : entries) { + if (!Sort.openapiFields.contains(entry.getKey())) { + throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Sort` properties. JSON: %s", entry.getKey(), jsonObj.toString())); + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Sort.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Sort' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Sort.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Sort value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + elementAdapter.write(out, obj); + } + + @Override + public Sort read(JsonReader in) throws IOException { + JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject(); + validateJsonObject(jsonObj); + return thisAdapter.fromJsonTree(jsonObj); + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Sort given an JSON string + * + * @param jsonString JSON string + * @return An instance of Sort + * @throws IOException if the JSON string is invalid with respect to Sort + */ + public static Sort fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Sort.class); + } + + /** + * Convert an instance of Sort to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } } + diff --git a/notification-service/README.md b/notification-service/README.md index 13ec909d7..c60562cae 100644 --- a/notification-service/README.md +++ b/notification-service/README.md @@ -44,7 +44,7 @@ From the root of the 'notification-service' folder, the follow command will star ```shell -java -jar -Dspring.profiles.active=local -Dserver.port=8081 target/notification-service-1.0.13-SNAPSHOT.jar +java -jar -Dspring.profiles.active=local -Dserver.port=8081 target/notification-service-1.0.13.jar ``` diff --git a/notification-service/licenses/THIRD-PARTY.txt b/notification-service/licenses/THIRD-PARTY.txt index cfb1a4046..77dd95cff 100644 --- a/notification-service/licenses/THIRD-PARTY.txt +++ b/notification-service/licenses/THIRD-PARTY.txt @@ -151,7 +151,7 @@ Lists of 158 third-party dependencies. (Apache License, Version 2.0) spring-security-oauth2-core (org.springframework.security:spring-security-oauth2-core:5.5.2 - https://spring.io/projects/spring-security) (Apache License, Version 2.0) spring-security-oauth2-jose (org.springframework.security:spring-security-oauth2-jose:5.5.2 - https://spring.io/projects/spring-security) (Apache License, Version 2.0) spring-security-oauth2-resource-server (org.springframework.security:spring-security-oauth2-resource-server:5.5.2 - https://spring.io/projects/spring-security) - (Apache 2.0) spring-security-rsa (org.springframework.security:spring-security-rsa:1.0.13-SNAPSHOT.RELEASE - http://github.com/spring-projects/spring-security-oauth) + (Apache 2.0) spring-security-rsa (org.springframework.security:spring-security-rsa:1.0.13.RELEASE - http://github.com/spring-projects/spring-security-oauth) (Apache License, Version 2.0) spring-security-test (org.springframework.security:spring-security-test:5.5.2 - https://spring.io/projects/spring-security) (Apache License, Version 2.0) spring-security-web (org.springframework.security:spring-security-web:5.5.2 - https://spring.io/projects/spring-security) (Apache 2.0) Swagger UI (org.webjars:swagger-ui:3.51.1 - http://webjars.org) diff --git a/notification-service/src/main/resources/application.yml b/notification-service/src/main/resources/application.yml index a7989305f..3805e6772 100644 --- a/notification-service/src/main/resources/application.yml +++ b/notification-service/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: application: name: parodos-notification-service title: Parodos Notification Service - version: 1.0.13-SNAPSHOT + version: 1.0.13 jackson: default-property-inclusion: non_null main: diff --git a/pom.xml b/pom.xml index be1bf7a03..8f3ef64ea 100644 --- a/pom.xml +++ b/pom.xml @@ -42,7 +42,7 @@ - 1.0.13-SNAPSHOT + 1.0.13 1.3.0 17 UTF-8 diff --git a/workflow-service-sdk/README.md b/workflow-service-sdk/README.md index c01deba0c..952d9dc9b 100644 --- a/workflow-service-sdk/README.md +++ b/workflow-service-sdk/README.md @@ -39,7 +39,7 @@ Add this dependency to your project's POM: dev.parodos workflow-service-sdk - 1.0.13-SNAPSHOT + 1.0.13 compile ``` @@ -55,7 +55,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "dev.parodos:workflow-service-sdk:1.0.13-SNAPSHOT" + implementation "dev.parodos:workflow-service-sdk:1.0.13" } ``` @@ -69,7 +69,7 @@ mvn clean package Then manually install the following JARs: -* `target/workflow-service-sdk-1.0.13-SNAPSHOT.jar` +* `target/workflow-service-sdk-1.0.13.jar` * `target/lib/*.jar` ## Getting Started diff --git a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/invoker/ApiClient.java b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/invoker/ApiClient.java index 2ab06fb13..fe810df5b 100644 --- a/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/invoker/ApiClient.java +++ b/workflow-service-sdk/src/main/java/com/redhat/parodos/sdk/invoker/ApiClient.java @@ -143,7 +143,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("OpenAPI-Generator/1.0.13-SNAPSHOT/java"); + setUserAgent("OpenAPI-Generator/1.0.13/java"); authentications = new HashMap(); } diff --git a/workflow-service/src/main/resources/application.yml b/workflow-service/src/main/resources/application.yml index ce8c54c44..054b97d13 100644 --- a/workflow-service/src/main/resources/application.yml +++ b/workflow-service/src/main/resources/application.yml @@ -2,7 +2,7 @@ spring: application: name: parodos-workflow-service title: Parodos Workflow Service - version: 1.0.13-SNAPSHOT + version: 1.0.13