diff --git a/.gitignore b/.gitignore index 2c3bf98dac0..d5f96f480e2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,6 @@ yarn-error.log **/dist .vscode +target + +**/.DS_Store diff --git a/clients/algoliasearch-client-java-2/.gitignore b/clients/algoliasearch-client-java-2/.gitignore new file mode 100644 index 00000000000..7cf2ea329dc --- /dev/null +++ b/clients/algoliasearch-client-java-2/.gitignore @@ -0,0 +1,20 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build + +.openapi-generator diff --git a/clients/algoliasearch-client-java-2/.openapi-generator-ignore b/clients/algoliasearch-client-java-2/.openapi-generator-ignore new file mode 100644 index 00000000000..ba2a2732751 --- /dev/null +++ b/clients/algoliasearch-client-java-2/.openapi-generator-ignore @@ -0,0 +1,21 @@ +# OpenAPI Generator Ignore +# Generated by openapi-generator https://github.com/openapitools/openapi-generator + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +api/** +docs/** +gradle/** +src/** + +.travis.yml +build.gradle +build.sbt +git_push.sh +gradle* +settings.gradle + +# Selective source file +algoliasearch-core/com/algolia/auth/** +algoliasearch-core/com/algolia/Configuration.java diff --git a/clients/algoliasearch-client-java-2/README.md b/clients/algoliasearch-client-java-2/README.md new file mode 100644 index 00000000000..d1fe04db28e --- /dev/null +++ b/clients/algoliasearch-client-java-2/README.md @@ -0,0 +1,68 @@ +# algoliasearch-client-java-2 + +Search API +- API version: 0.1.0 + +API powering the Search feature of Algolia. + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: +1. Java 1.8+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + com.algolia + algoliasearch-client-java-2 + 0.1.0 + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "com.algolia:algoliasearch-client-java-2:0.1.0" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +* `target/algoliasearch-client-java-2-0.1.0.jar` +* `target/lib/*.jar` + +## Getting Started + +Checkout the playground. diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiCallback.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiCallback.java new file mode 100644 index 00000000000..6b149c2b325 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiCallback.java @@ -0,0 +1,55 @@ +package com.algolia; + +import java.util.List; +import java.util.Map; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure( + ApiException e, + int statusCode, + Map> responseHeaders + ); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess( + T result, + int statusCode, + Map> responseHeaders + ); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java new file mode 100644 index 00000000000..6bca7ae6f29 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiClient.java @@ -0,0 +1,1238 @@ +package com.algolia; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.text.DateFormat; +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import javax.net.ssl.*; +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; + +public class ApiClient { + + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + + private String basePath; + private String appId, apiKey; + + 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(String appId, String apiKey) { + init(); + initHttpClient(); + + this.basePath = "https://" + appId + "-1.algolianet.com"; + this.appId = appId; + this.apiKey = apiKey; + } + + 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/0.1.0/java"); + } + + /** + * 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; + } + + 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; + } + + public DateFormat getDateFormat() { + return dateFormat; + } + + public ApiClient setDateFormat(DateFormat dateFormat) { + this.json.setDateFormat(dateFormat); + return this; + } + + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + this.json.setSqlDateFormat(dateFormat); + return this; + } + + public ApiClient setLenientOnJson(boolean lenientOnJson) { + this.json.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = + httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * 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 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 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 Integer#MAX_VALUE}. + * + * @param writeTimeout connection timeout in milliseconds + * @return Api client + */ + public ApiClient setWriteTimeout(int writeTimeout) { + httpClient = + httpClient + .newBuilder() + .writeTimeout(writeTimeout, TimeUnit.MILLISECONDS) + .build(); + return this; + } + + /** + * Format the given parameter object into string. + * + * @param param Parameter + * @return String representation of the parameter + */ + public String parameterToString(Object param) { + if (param == null) { + return ""; + } else if ( + param instanceof Date || + param instanceof OffsetDateTime || + param instanceof LocalDate + ) { + // Serialize to json string and remove the " enclosing characters + String jsonStr = json.serialize(param); + return jsonStr.substring(1, jsonStr.length() - 1); + } else if (param instanceof Collection) { + StringBuilder b = new StringBuilder(); + for (Object o : (Collection) param) { + if (b.length() > 0) { + b.append(","); + } + b.append(String.valueOf(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, or matches "any", JSON + * will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0 || 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 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); + } + } + + 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 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 (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = json.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else { + throw new ApiException( + "Content type \"" + contentType + "\" is not supported" + ); + } + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws 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 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 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 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 ApiException If fail to serialize the request body object + */ + public Call buildCall( + 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( + path, + method, + queryParams, + collectionQueryParams, + body, + headerParams, + cookieParams, + formParams, + authNames, + callback + ); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @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 ApiException If fail to serialize the request body object + */ + public Request buildRequest( + String path, + String method, + List queryParams, + List collectionQueryParams, + Object body, + Map headerParams, + Map cookieParams, + Map formParams, + String[] authNames, + ApiCallback callback + ) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + + final String url = buildUrl(path, queryParams, collectionQueryParams); + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + String contentType = (String) headerParams.get("Content-Type"); + // ensuring a default content type + if (contentType == null) { + contentType = "application/json"; + } + + RequestBody reqBody; + 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("", MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // 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 path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl( + String path, + List queryParams, + List collectionQueryParams + ) { + final StringBuilder url = new StringBuilder(); + url.append(basePath).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 + */ + public void updateParamsForAuth( + String[] authNames, + List queryParams, + Map headerParams, + Map cookieParams + ) { + headerParams.put("X-Algolia-Application-Id", this.appId); + headerParams.put("X-Algolia-API-Key", this.apiKey); + } + + /** + * 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(); + Headers partHeaders = Headers.of( + "Content-Disposition", + "form-data; name=\"" + + param.getKey() + + "\"; filename=\"" + + file.getName() + + "\"" + ); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } else { + Headers partHeaders = Headers.of( + "Content-Disposition", + "form-data; name=\"" + param.getKey() + "\"" + ); + mpBuilder.addPart( + partHeaders, + RequestBody.create(parameterToString(param.getValue()), null) + ); + } + } + 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; + } + } + + /** + * 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" + Integer.toString(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); + } + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiException.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiException.java new file mode 100644 index 00000000000..06c74f5cc5b --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiException.java @@ -0,0 +1,103 @@ +package com.algolia; + +import java.util.List; +import java.util.Map; + +public class ApiException extends Exception { + + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException( + String message, + Throwable throwable, + int code, + Map> responseHeaders, + String responseBody + ) { + super(message, throwable); + this.code = code; + this.responseHeaders = responseHeaders; + this.responseBody = responseBody; + } + + public ApiException( + String message, + int code, + Map> responseHeaders, + String responseBody + ) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException( + String message, + Throwable throwable, + int code, + Map> responseHeaders + ) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException( + int code, + Map> responseHeaders, + String responseBody + ) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + 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; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiResponse.java new file mode 100644 index 00000000000..3826fd07542 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ApiResponse.java @@ -0,0 +1,51 @@ +package com.algolia; + +import java.util.List; +import java.util.Map; + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + + private final int statusCode; + private final Map> headers; + private final T data; + + /** + * @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); + } + + /** + * @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; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/GzipRequestInterceptor.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/GzipRequestInterceptor.java new file mode 100644 index 00000000000..3a054245399 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/GzipRequestInterceptor.java @@ -0,0 +1,80 @@ +package com.algolia; + +import java.io.IOException; +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +/** + * Encodes request bodies using gzip. + * + *

Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if ( + originalRequest.body() == null || + originalRequest.header("Content-Encoding") != null + ) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest + .newBuilder() + .header("Content-Encoding", "gzip") + .method( + originalRequest.method(), + forceContentLength(gzip(originalRequest.body())) + ) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) + throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java new file mode 100644 index 00000000000..fff9b8547c2 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/JSON.java @@ -0,0 +1,392 @@ +package com.algolia; + +import com.algolia.model.*; +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonElement; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import io.gsonfire.GsonFireBuilder; +import java.io.IOException; +import java.io.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.Map; +import okio.ByteString; + +public class JSON { + + private Gson gson; + private boolean isLenientOnJson = false; + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + private 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; + } + + public JSON() { + gson = + createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + .registerTypeAdapter(byte[].class, byteArrayAdapter) + .create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public 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 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 class ByteArrayAdapter extends TypeAdapter { + + @Override + public void write(JsonWriter out, byte[] value) throws IOException { + if (value == null) { + out.nullValue(); + } else { + out.value(ByteString.of(value).base64()); + } + } + + @Override + public byte[] read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String bytesAsBase64 = in.nextString(); + ByteString byteString = ByteString.decodeBase64(bytesAsBase64); + return byteString.toByteArray(); + } + } + } + + /** Gson TypeAdapter for JSR310 OffsetDateTime type */ + public static class OffsetDateTimeTypeAdapter + extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length() - 5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** Gson TypeAdapter for JSR310 LocalDate type */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + /** + * 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 JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/Pair.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/Pair.java new file mode 100644 index 00000000000..1e5bf539ea2 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/Pair.java @@ -0,0 +1,48 @@ +package com.algolia; + +public class Pair { + + private String name = ""; + private String value = ""; + + public Pair(String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + if (arg.trim().isEmpty()) { + return false; + } + + return true; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressRequestBody.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressRequestBody.java new file mode 100644 index 00000000000..42c926955cc --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressRequestBody.java @@ -0,0 +1,61 @@ +package com.algolia; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.RequestBody; +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress( + bytesWritten, + contentLength, + bytesWritten == contentLength + ); + } + }; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressResponseBody.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressResponseBody.java new file mode 100644 index 00000000000..d5f13aa6e50 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ProgressResponseBody.java @@ -0,0 +1,59 @@ +package com.algolia; + +import java.io.IOException; +import okhttp3.MediaType; +import okhttp3.ResponseBody; +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress( + totalBytesRead, + responseBody.contentLength(), + bytesRead == -1 + ); + return bytesRead; + } + }; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerConfiguration.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerConfiguration.java new file mode 100644 index 00000000000..2079f056c98 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerConfiguration.java @@ -0,0 +1,71 @@ +package com.algolia; + +import java.util.Map; + +/** 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 RuntimeException( + "The variable " + + name + + " in the server URL has invalid value " + + value + + "." + ); + } + } + url = url.replaceAll("\\{" + name + "\\}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerVariable.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerVariable.java new file mode 100644 index 00000000000..c0e8b2aa675 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/ServerVariable.java @@ -0,0 +1,27 @@ +package com.algolia; + +import java.util.HashSet; + +/** Representing a Server Variable for server URL template substitution. */ +public class ServerVariable { + + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are + * from a limited set. + */ + public ServerVariable( + String description, + String defaultValue, + HashSet enumValues + ) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/StringUtil.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/StringUtil.java new file mode 100644 index 00000000000..af841ec05cd --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/StringUtil.java @@ -0,0 +1,69 @@ +package com.algolia; + +import java.util.Collection; +import java.util.Iterator; + +public class StringUtil { + + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + * + *

Note: This might be replaced by utility method from commons-lang or guava someday if one of + * those libraries is added as dependency. + * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseIndexSettings.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseIndexSettings.java new file mode 100644 index 00000000000..5ac1b4dfa23 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseIndexSettings.java @@ -0,0 +1,583 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** BaseIndexSettings */ +public class BaseIndexSettings { + + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + + @SerializedName(SERIALIZED_NAME_REPLICAS) + private List replicas = null; + + public static final String SERIALIZED_NAME_PAGINATION_LIMITED_TO = + "paginationLimitedTo"; + + @SerializedName(SERIALIZED_NAME_PAGINATION_LIMITED_TO) + private Integer paginationLimitedTo = 1000; + + public static final String SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_WORDS = + "disableTypoToleranceOnWords"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_WORDS) + private List disableTypoToleranceOnWords = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_TRANSLITERATE = + "attributesToTransliterate"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_TRANSLITERATE) + private List attributesToTransliterate = null; + + public static final String SERIALIZED_NAME_CAMEL_CASE_ATTRIBUTES = + "camelCaseAttributes"; + + @SerializedName(SERIALIZED_NAME_CAMEL_CASE_ATTRIBUTES) + private List camelCaseAttributes = null; + + public static final String SERIALIZED_NAME_DECOMPOUNDED_ATTRIBUTES = + "decompoundedAttributes"; + + @SerializedName(SERIALIZED_NAME_DECOMPOUNDED_ATTRIBUTES) + private Map decompoundedAttributes = null; + + public static final String SERIALIZED_NAME_INDEX_LANGUAGES = "indexLanguages"; + + @SerializedName(SERIALIZED_NAME_INDEX_LANGUAGES) + private List indexLanguages = null; + + public static final String SERIALIZED_NAME_FILTER_PROMOTES = "filterPromotes"; + + @SerializedName(SERIALIZED_NAME_FILTER_PROMOTES) + private Boolean filterPromotes = false; + + public static final String SERIALIZED_NAME_DISABLE_PREFIX_ON_ATTRIBUTES = + "disablePrefixOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_PREFIX_ON_ATTRIBUTES) + private List disablePrefixOnAttributes = null; + + public static final String SERIALIZED_NAME_ALLOW_COMPRESSION_OF_INTEGER_ARRAY = + "allowCompressionOfIntegerArray"; + + @SerializedName(SERIALIZED_NAME_ALLOW_COMPRESSION_OF_INTEGER_ARRAY) + private Boolean allowCompressionOfIntegerArray = false; + + public static final String SERIALIZED_NAME_NUMERIC_ATTRIBUTES_FOR_FILTERING = + "numericAttributesForFiltering"; + + @SerializedName(SERIALIZED_NAME_NUMERIC_ATTRIBUTES_FOR_FILTERING) + private List numericAttributesForFiltering = null; + + public static final String SERIALIZED_NAME_USER_DATA = "userData"; + + @SerializedName(SERIALIZED_NAME_USER_DATA) + private Map userData = null; + + public BaseIndexSettings replicas(List replicas) { + this.replicas = replicas; + return this; + } + + public BaseIndexSettings addReplicasItem(String replicasItem) { + if (this.replicas == null) { + this.replicas = new ArrayList<>(); + } + this.replicas.add(replicasItem); + return this; + } + + /** + * Creates replicas, exact copies of an index. + * + * @return replicas + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Creates replicas, exact copies of an index.") + public List getReplicas() { + return replicas; + } + + public void setReplicas(List replicas) { + this.replicas = replicas; + } + + public BaseIndexSettings paginationLimitedTo(Integer paginationLimitedTo) { + this.paginationLimitedTo = paginationLimitedTo; + return this; + } + + /** + * Set the maximum number of hits accessible via pagination. + * + * @return paginationLimitedTo + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Set the maximum number of hits accessible via pagination." + ) + public Integer getPaginationLimitedTo() { + return paginationLimitedTo; + } + + public void setPaginationLimitedTo(Integer paginationLimitedTo) { + this.paginationLimitedTo = paginationLimitedTo; + } + + public BaseIndexSettings disableTypoToleranceOnWords( + List disableTypoToleranceOnWords + ) { + this.disableTypoToleranceOnWords = disableTypoToleranceOnWords; + return this; + } + + public BaseIndexSettings addDisableTypoToleranceOnWordsItem( + String disableTypoToleranceOnWordsItem + ) { + if (this.disableTypoToleranceOnWords == null) { + this.disableTypoToleranceOnWords = new ArrayList<>(); + } + this.disableTypoToleranceOnWords.add(disableTypoToleranceOnWordsItem); + return this; + } + + /** + * A list of words for which you want to turn off typo tolerance. + * + * @return disableTypoToleranceOnWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A list of words for which you want to turn off typo tolerance." + ) + public List getDisableTypoToleranceOnWords() { + return disableTypoToleranceOnWords; + } + + public void setDisableTypoToleranceOnWords( + List disableTypoToleranceOnWords + ) { + this.disableTypoToleranceOnWords = disableTypoToleranceOnWords; + } + + public BaseIndexSettings attributesToTransliterate( + List attributesToTransliterate + ) { + this.attributesToTransliterate = attributesToTransliterate; + return this; + } + + public BaseIndexSettings addAttributesToTransliterateItem( + String attributesToTransliterateItem + ) { + if (this.attributesToTransliterate == null) { + this.attributesToTransliterate = new ArrayList<>(); + } + this.attributesToTransliterate.add(attributesToTransliterateItem); + return this; + } + + /** + * Specify on which attributes to apply transliteration. + * + * @return attributesToTransliterate + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Specify on which attributes to apply transliteration." + ) + public List getAttributesToTransliterate() { + return attributesToTransliterate; + } + + public void setAttributesToTransliterate( + List attributesToTransliterate + ) { + this.attributesToTransliterate = attributesToTransliterate; + } + + public BaseIndexSettings camelCaseAttributes( + List camelCaseAttributes + ) { + this.camelCaseAttributes = camelCaseAttributes; + return this; + } + + public BaseIndexSettings addCamelCaseAttributesItem( + String camelCaseAttributesItem + ) { + if (this.camelCaseAttributes == null) { + this.camelCaseAttributes = new ArrayList<>(); + } + this.camelCaseAttributes.add(camelCaseAttributesItem); + return this; + } + + /** + * List of attributes on which to do a decomposition of camel case words. + * + * @return camelCaseAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which to do a decomposition of camel case words." + ) + public List getCamelCaseAttributes() { + return camelCaseAttributes; + } + + public void setCamelCaseAttributes(List camelCaseAttributes) { + this.camelCaseAttributes = camelCaseAttributes; + } + + public BaseIndexSettings decompoundedAttributes( + Map decompoundedAttributes + ) { + this.decompoundedAttributes = decompoundedAttributes; + return this; + } + + public BaseIndexSettings putDecompoundedAttributesItem( + String key, + Object decompoundedAttributesItem + ) { + if (this.decompoundedAttributes == null) { + this.decompoundedAttributes = new HashMap<>(); + } + this.decompoundedAttributes.put(key, decompoundedAttributesItem); + return this; + } + + /** + * Specify on which attributes in your index Algolia should apply word segmentation, also known as + * decompounding. + * + * @return decompoundedAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Specify on which attributes in your index Algolia should apply word segmentation, also" + + " known as decompounding." + ) + public Map getDecompoundedAttributes() { + return decompoundedAttributes; + } + + public void setDecompoundedAttributes( + Map decompoundedAttributes + ) { + this.decompoundedAttributes = decompoundedAttributes; + } + + public BaseIndexSettings indexLanguages(List indexLanguages) { + this.indexLanguages = indexLanguages; + return this; + } + + public BaseIndexSettings addIndexLanguagesItem(String indexLanguagesItem) { + if (this.indexLanguages == null) { + this.indexLanguages = new ArrayList<>(); + } + this.indexLanguages.add(indexLanguagesItem); + return this; + } + + /** + * Sets the languages at the index level for language-specific processing such as tokenization and + * normalization. + * + * @return indexLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Sets the languages at the index level for language-specific processing such as" + + " tokenization and normalization." + ) + public List getIndexLanguages() { + return indexLanguages; + } + + public void setIndexLanguages(List indexLanguages) { + this.indexLanguages = indexLanguages; + } + + public BaseIndexSettings filterPromotes(Boolean filterPromotes) { + this.filterPromotes = filterPromotes; + return this; + } + + /** + * Whether promoted results should match the filters of the current search, except for geographic + * filters. + * + * @return filterPromotes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether promoted results should match the filters of the current search, except for" + + " geographic filters." + ) + public Boolean getFilterPromotes() { + return filterPromotes; + } + + public void setFilterPromotes(Boolean filterPromotes) { + this.filterPromotes = filterPromotes; + } + + public BaseIndexSettings disablePrefixOnAttributes( + List disablePrefixOnAttributes + ) { + this.disablePrefixOnAttributes = disablePrefixOnAttributes; + return this; + } + + public BaseIndexSettings addDisablePrefixOnAttributesItem( + String disablePrefixOnAttributesItem + ) { + if (this.disablePrefixOnAttributes == null) { + this.disablePrefixOnAttributes = new ArrayList<>(); + } + this.disablePrefixOnAttributes.add(disablePrefixOnAttributesItem); + return this; + } + + /** + * List of attributes on which you want to disable prefix matching. + * + * @return disablePrefixOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable prefix matching." + ) + public List getDisablePrefixOnAttributes() { + return disablePrefixOnAttributes; + } + + public void setDisablePrefixOnAttributes( + List disablePrefixOnAttributes + ) { + this.disablePrefixOnAttributes = disablePrefixOnAttributes; + } + + public BaseIndexSettings allowCompressionOfIntegerArray( + Boolean allowCompressionOfIntegerArray + ) { + this.allowCompressionOfIntegerArray = allowCompressionOfIntegerArray; + return this; + } + + /** + * Enables compression of large integer arrays. + * + * @return allowCompressionOfIntegerArray + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables compression of large integer arrays.") + public Boolean getAllowCompressionOfIntegerArray() { + return allowCompressionOfIntegerArray; + } + + public void setAllowCompressionOfIntegerArray( + Boolean allowCompressionOfIntegerArray + ) { + this.allowCompressionOfIntegerArray = allowCompressionOfIntegerArray; + } + + public BaseIndexSettings numericAttributesForFiltering( + List numericAttributesForFiltering + ) { + this.numericAttributesForFiltering = numericAttributesForFiltering; + return this; + } + + public BaseIndexSettings addNumericAttributesForFilteringItem( + String numericAttributesForFilteringItem + ) { + if (this.numericAttributesForFiltering == null) { + this.numericAttributesForFiltering = new ArrayList<>(); + } + this.numericAttributesForFiltering.add(numericAttributesForFilteringItem); + return this; + } + + /** + * List of numeric attributes that can be used as numerical filters. + * + * @return numericAttributesForFiltering + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of numeric attributes that can be used as numerical filters." + ) + public List getNumericAttributesForFiltering() { + return numericAttributesForFiltering; + } + + public void setNumericAttributesForFiltering( + List numericAttributesForFiltering + ) { + this.numericAttributesForFiltering = numericAttributesForFiltering; + } + + public BaseIndexSettings userData(Map userData) { + this.userData = userData; + return this; + } + + public BaseIndexSettings putUserDataItem(String key, Object userDataItem) { + if (this.userData == null) { + this.userData = new HashMap<>(); + } + this.userData.put(key, userDataItem); + return this; + } + + /** + * Lets you store custom data in your indices. + * + * @return userData + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Lets you store custom data in your indices.") + public Map getUserData() { + return userData; + } + + public void setUserData(Map userData) { + this.userData = userData; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseIndexSettings baseIndexSettings = (BaseIndexSettings) o; + return ( + Objects.equals(this.replicas, baseIndexSettings.replicas) && + Objects.equals( + this.paginationLimitedTo, + baseIndexSettings.paginationLimitedTo + ) && + Objects.equals( + this.disableTypoToleranceOnWords, + baseIndexSettings.disableTypoToleranceOnWords + ) && + Objects.equals( + this.attributesToTransliterate, + baseIndexSettings.attributesToTransliterate + ) && + Objects.equals( + this.camelCaseAttributes, + baseIndexSettings.camelCaseAttributes + ) && + Objects.equals( + this.decompoundedAttributes, + baseIndexSettings.decompoundedAttributes + ) && + Objects.equals(this.indexLanguages, baseIndexSettings.indexLanguages) && + Objects.equals(this.filterPromotes, baseIndexSettings.filterPromotes) && + Objects.equals( + this.disablePrefixOnAttributes, + baseIndexSettings.disablePrefixOnAttributes + ) && + Objects.equals( + this.allowCompressionOfIntegerArray, + baseIndexSettings.allowCompressionOfIntegerArray + ) && + Objects.equals( + this.numericAttributesForFiltering, + baseIndexSettings.numericAttributesForFiltering + ) && + Objects.equals(this.userData, baseIndexSettings.userData) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + replicas, + paginationLimitedTo, + disableTypoToleranceOnWords, + attributesToTransliterate, + camelCaseAttributes, + decompoundedAttributes, + indexLanguages, + filterPromotes, + disablePrefixOnAttributes, + allowCompressionOfIntegerArray, + numericAttributesForFiltering, + userData + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseIndexSettings {\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb + .append(" paginationLimitedTo: ") + .append(toIndentedString(paginationLimitedTo)) + .append("\n"); + sb + .append(" disableTypoToleranceOnWords: ") + .append(toIndentedString(disableTypoToleranceOnWords)) + .append("\n"); + sb + .append(" attributesToTransliterate: ") + .append(toIndentedString(attributesToTransliterate)) + .append("\n"); + sb + .append(" camelCaseAttributes: ") + .append(toIndentedString(camelCaseAttributes)) + .append("\n"); + sb + .append(" decompoundedAttributes: ") + .append(toIndentedString(decompoundedAttributes)) + .append("\n"); + sb + .append(" indexLanguages: ") + .append(toIndentedString(indexLanguages)) + .append("\n"); + sb + .append(" filterPromotes: ") + .append(toIndentedString(filterPromotes)) + .append("\n"); + sb + .append(" disablePrefixOnAttributes: ") + .append(toIndentedString(disablePrefixOnAttributes)) + .append("\n"); + sb + .append(" allowCompressionOfIntegerArray: ") + .append(toIndentedString(allowCompressionOfIntegerArray)) + .append("\n"); + sb + .append(" numericAttributesForFiltering: ") + .append(toIndentedString(numericAttributesForFiltering)) + .append("\n"); + sb.append(" userData: ").append(toIndentedString(userData)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchParams.java new file mode 100644 index 00000000000..504405ca146 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchParams.java @@ -0,0 +1,1261 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** BaseSearchParams */ +public class BaseSearchParams { + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + public static final String SERIALIZED_NAME_SIMILAR_QUERY = "similarQuery"; + + @SerializedName(SERIALIZED_NAME_SIMILAR_QUERY) + private String similarQuery = ""; + + public static final String SERIALIZED_NAME_FILTERS = "filters"; + + @SerializedName(SERIALIZED_NAME_FILTERS) + private String filters = ""; + + public static final String SERIALIZED_NAME_FACET_FILTERS = "facetFilters"; + + @SerializedName(SERIALIZED_NAME_FACET_FILTERS) + private List facetFilters = null; + + public static final String SERIALIZED_NAME_OPTIONAL_FILTERS = + "optionalFilters"; + + @SerializedName(SERIALIZED_NAME_OPTIONAL_FILTERS) + private List optionalFilters = null; + + public static final String SERIALIZED_NAME_NUMERIC_FILTERS = "numericFilters"; + + @SerializedName(SERIALIZED_NAME_NUMERIC_FILTERS) + private List numericFilters = null; + + public static final String SERIALIZED_NAME_TAG_FILTERS = "tagFilters"; + + @SerializedName(SERIALIZED_NAME_TAG_FILTERS) + private List tagFilters = null; + + public static final String SERIALIZED_NAME_SUM_OR_FILTERS_SCORES = + "sumOrFiltersScores"; + + @SerializedName(SERIALIZED_NAME_SUM_OR_FILTERS_SCORES) + private Boolean sumOrFiltersScores = false; + + public static final String SERIALIZED_NAME_FACETS = "facets"; + + @SerializedName(SERIALIZED_NAME_FACETS) + private List facets = null; + + public static final String SERIALIZED_NAME_MAX_VALUES_PER_FACET = + "maxValuesPerFacet"; + + @SerializedName(SERIALIZED_NAME_MAX_VALUES_PER_FACET) + private Integer maxValuesPerFacet = 100; + + public static final String SERIALIZED_NAME_FACETING_AFTER_DISTINCT = + "facetingAfterDistinct"; + + @SerializedName(SERIALIZED_NAME_FACETING_AFTER_DISTINCT) + private Boolean facetingAfterDistinct = false; + + public static final String SERIALIZED_NAME_SORT_FACET_VALUES_BY = + "sortFacetValuesBy"; + + @SerializedName(SERIALIZED_NAME_SORT_FACET_VALUES_BY) + private String sortFacetValuesBy = "count"; + + public static final String SERIALIZED_NAME_PAGE = "page"; + + @SerializedName(SERIALIZED_NAME_PAGE) + private Integer page = 0; + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + + @SerializedName(SERIALIZED_NAME_OFFSET) + private Integer offset; + + public static final String SERIALIZED_NAME_LENGTH = "length"; + + @SerializedName(SERIALIZED_NAME_LENGTH) + private Integer length; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG = "aroundLatLng"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG) + private String aroundLatLng = ""; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG_VIA_I_P = + "aroundLatLngViaIP"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG_VIA_I_P) + private Boolean aroundLatLngViaIP = false; + + public static final String SERIALIZED_NAME_AROUND_RADIUS = "aroundRadius"; + + @SerializedName(SERIALIZED_NAME_AROUND_RADIUS) + private OneOfintegerstring aroundRadius; + + public static final String SERIALIZED_NAME_AROUND_PRECISION = + "aroundPrecision"; + + @SerializedName(SERIALIZED_NAME_AROUND_PRECISION) + private Integer aroundPrecision = 10; + + public static final String SERIALIZED_NAME_MINIMUM_AROUND_RADIUS = + "minimumAroundRadius"; + + @SerializedName(SERIALIZED_NAME_MINIMUM_AROUND_RADIUS) + private Integer minimumAroundRadius; + + public static final String SERIALIZED_NAME_INSIDE_BOUNDING_BOX = + "insideBoundingBox"; + + @SerializedName(SERIALIZED_NAME_INSIDE_BOUNDING_BOX) + private List insideBoundingBox = null; + + public static final String SERIALIZED_NAME_INSIDE_POLYGON = "insidePolygon"; + + @SerializedName(SERIALIZED_NAME_INSIDE_POLYGON) + private List insidePolygon = null; + + public static final String SERIALIZED_NAME_NATURAL_LANGUAGES = + "naturalLanguages"; + + @SerializedName(SERIALIZED_NAME_NATURAL_LANGUAGES) + private List naturalLanguages = null; + + public static final String SERIALIZED_NAME_RULE_CONTEXTS = "ruleContexts"; + + @SerializedName(SERIALIZED_NAME_RULE_CONTEXTS) + private List ruleContexts = null; + + public static final String SERIALIZED_NAME_PERSONALIZATION_IMPACT = + "personalizationImpact"; + + @SerializedName(SERIALIZED_NAME_PERSONALIZATION_IMPACT) + private Integer personalizationImpact = 100; + + public static final String SERIALIZED_NAME_USER_TOKEN = "userToken"; + + @SerializedName(SERIALIZED_NAME_USER_TOKEN) + private String userToken; + + public static final String SERIALIZED_NAME_GET_RANKING_INFO = + "getRankingInfo"; + + @SerializedName(SERIALIZED_NAME_GET_RANKING_INFO) + private Boolean getRankingInfo = false; + + public static final String SERIALIZED_NAME_CLICK_ANALYTICS = "clickAnalytics"; + + @SerializedName(SERIALIZED_NAME_CLICK_ANALYTICS) + private Boolean clickAnalytics = false; + + public static final String SERIALIZED_NAME_ANALYTICS = "analytics"; + + @SerializedName(SERIALIZED_NAME_ANALYTICS) + private Boolean analytics = true; + + public static final String SERIALIZED_NAME_ANALYTICS_TAGS = "analyticsTags"; + + @SerializedName(SERIALIZED_NAME_ANALYTICS_TAGS) + private List analyticsTags = null; + + public static final String SERIALIZED_NAME_PERCENTILE_COMPUTATION = + "percentileComputation"; + + @SerializedName(SERIALIZED_NAME_PERCENTILE_COMPUTATION) + private Boolean percentileComputation = true; + + public static final String SERIALIZED_NAME_ENABLE_A_B_TEST = "enableABTest"; + + @SerializedName(SERIALIZED_NAME_ENABLE_A_B_TEST) + private Boolean enableABTest = true; + + public static final String SERIALIZED_NAME_ENABLE_RE_RANKING = + "enableReRanking"; + + @SerializedName(SERIALIZED_NAME_ENABLE_RE_RANKING) + private Boolean enableReRanking = true; + + public BaseSearchParams query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public BaseSearchParams similarQuery(String similarQuery) { + this.similarQuery = similarQuery; + return this; + } + + /** + * Overrides the query parameter and performs a more generic search that can be used to find + * \"similar\" results. + * + * @return similarQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Overrides the query parameter and performs a more generic search that can be used to" + + " find \"similar\" results." + ) + public String getSimilarQuery() { + return similarQuery; + } + + public void setSimilarQuery(String similarQuery) { + this.similarQuery = similarQuery; + } + + public BaseSearchParams filters(String filters) { + this.filters = filters; + return this; + } + + /** + * Filter the query with numeric, facet and/or tag filters. + * + * @return filters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Filter the query with numeric, facet and/or tag filters." + ) + public String getFilters() { + return filters; + } + + public void setFilters(String filters) { + this.filters = filters; + } + + public BaseSearchParams facetFilters(List facetFilters) { + this.facetFilters = facetFilters; + return this; + } + + public BaseSearchParams addFacetFiltersItem(String facetFiltersItem) { + if (this.facetFilters == null) { + this.facetFilters = new ArrayList<>(); + } + this.facetFilters.add(facetFiltersItem); + return this; + } + + /** + * Filter hits by facet value. + * + * @return facetFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter hits by facet value.") + public List getFacetFilters() { + return facetFilters; + } + + public void setFacetFilters(List facetFilters) { + this.facetFilters = facetFilters; + } + + public BaseSearchParams optionalFilters(List optionalFilters) { + this.optionalFilters = optionalFilters; + return this; + } + + public BaseSearchParams addOptionalFiltersItem(String optionalFiltersItem) { + if (this.optionalFilters == null) { + this.optionalFilters = new ArrayList<>(); + } + this.optionalFilters.add(optionalFiltersItem); + return this; + } + + /** + * Create filters for ranking purposes, where records that match the filter are ranked higher, or + * lower in the case of a negative optional filter. + * + * @return optionalFilters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Create filters for ranking purposes, where records that match the filter are ranked" + + " higher, or lower in the case of a negative optional filter." + ) + public List getOptionalFilters() { + return optionalFilters; + } + + public void setOptionalFilters(List optionalFilters) { + this.optionalFilters = optionalFilters; + } + + public BaseSearchParams numericFilters(List numericFilters) { + this.numericFilters = numericFilters; + return this; + } + + public BaseSearchParams addNumericFiltersItem(String numericFiltersItem) { + if (this.numericFilters == null) { + this.numericFilters = new ArrayList<>(); + } + this.numericFilters.add(numericFiltersItem); + return this; + } + + /** + * Filter on numeric attributes. + * + * @return numericFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter on numeric attributes.") + public List getNumericFilters() { + return numericFilters; + } + + public void setNumericFilters(List numericFilters) { + this.numericFilters = numericFilters; + } + + public BaseSearchParams tagFilters(List tagFilters) { + this.tagFilters = tagFilters; + return this; + } + + public BaseSearchParams addTagFiltersItem(String tagFiltersItem) { + if (this.tagFilters == null) { + this.tagFilters = new ArrayList<>(); + } + this.tagFilters.add(tagFiltersItem); + return this; + } + + /** + * Filter hits by tags. + * + * @return tagFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter hits by tags.") + public List getTagFilters() { + return tagFilters; + } + + public void setTagFilters(List tagFilters) { + this.tagFilters = tagFilters; + } + + public BaseSearchParams sumOrFiltersScores(Boolean sumOrFiltersScores) { + this.sumOrFiltersScores = sumOrFiltersScores; + return this; + } + + /** + * Determines how to calculate the total score for filtering. + * + * @return sumOrFiltersScores + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Determines how to calculate the total score for filtering." + ) + public Boolean getSumOrFiltersScores() { + return sumOrFiltersScores; + } + + public void setSumOrFiltersScores(Boolean sumOrFiltersScores) { + this.sumOrFiltersScores = sumOrFiltersScores; + } + + public BaseSearchParams facets(List facets) { + this.facets = facets; + return this; + } + + public BaseSearchParams addFacetsItem(String facetsItem) { + if (this.facets == null) { + this.facets = new ArrayList<>(); + } + this.facets.add(facetsItem); + return this; + } + + /** + * Retrieve facets and their facet values. + * + * @return facets + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Retrieve facets and their facet values.") + public List getFacets() { + return facets; + } + + public void setFacets(List facets) { + this.facets = facets; + } + + public BaseSearchParams maxValuesPerFacet(Integer maxValuesPerFacet) { + this.maxValuesPerFacet = maxValuesPerFacet; + return this; + } + + /** + * Maximum number of facet values to return for each facet during a regular search. + * + * @return maxValuesPerFacet + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet values to return for each facet during a regular search." + ) + public Integer getMaxValuesPerFacet() { + return maxValuesPerFacet; + } + + public void setMaxValuesPerFacet(Integer maxValuesPerFacet) { + this.maxValuesPerFacet = maxValuesPerFacet; + } + + public BaseSearchParams facetingAfterDistinct(Boolean facetingAfterDistinct) { + this.facetingAfterDistinct = facetingAfterDistinct; + return this; + } + + /** + * Force faceting to be applied after de-duplication (via the Distinct setting). + * + * @return facetingAfterDistinct + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Force faceting to be applied after de-duplication (via the Distinct setting)." + ) + public Boolean getFacetingAfterDistinct() { + return facetingAfterDistinct; + } + + public void setFacetingAfterDistinct(Boolean facetingAfterDistinct) { + this.facetingAfterDistinct = facetingAfterDistinct; + } + + public BaseSearchParams sortFacetValuesBy(String sortFacetValuesBy) { + this.sortFacetValuesBy = sortFacetValuesBy; + return this; + } + + /** + * Controls how facet values are fetched. + * + * @return sortFacetValuesBy + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Controls how facet values are fetched.") + public String getSortFacetValuesBy() { + return sortFacetValuesBy; + } + + public void setSortFacetValuesBy(String sortFacetValuesBy) { + this.sortFacetValuesBy = sortFacetValuesBy; + } + + public BaseSearchParams page(Integer page) { + this.page = page; + return this; + } + + /** + * Specify the page to retrieve. + * + * @return page + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specify the page to retrieve.") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public BaseSearchParams offset(Integer offset) { + this.offset = offset; + return this; + } + + /** + * Specify the offset of the first hit to return. + * + * @return offset + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specify the offset of the first hit to return.") + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public BaseSearchParams length(Integer length) { + this.length = length; + return this; + } + + /** + * Set the number of hits to retrieve (used only with offset). minimum: 1 maximum: 1000 + * + * @return length + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Set the number of hits to retrieve (used only with offset)." + ) + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public BaseSearchParams aroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + return this; + } + + /** + * Search for entries around a central geolocation, enabling a geo search within a circular area. + * + * @return aroundLatLng + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search for entries around a central geolocation, enabling a geo search within a circular" + + " area." + ) + public String getAroundLatLng() { + return aroundLatLng; + } + + public void setAroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + } + + public BaseSearchParams aroundLatLngViaIP(Boolean aroundLatLngViaIP) { + this.aroundLatLngViaIP = aroundLatLngViaIP; + return this; + } + + /** + * Search for entries around a given location automatically computed from the requester’s IP + * address. + * + * @return aroundLatLngViaIP + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search for entries around a given location automatically computed from the requester’s" + + " IP address." + ) + public Boolean getAroundLatLngViaIP() { + return aroundLatLngViaIP; + } + + public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { + this.aroundLatLngViaIP = aroundLatLngViaIP; + } + + public BaseSearchParams aroundRadius(OneOfintegerstring aroundRadius) { + this.aroundRadius = aroundRadius; + return this; + } + + /** + * Define the maximum radius for a geo search (in meters). + * + * @return aroundRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Define the maximum radius for a geo search (in meters)." + ) + public OneOfintegerstring getAroundRadius() { + return aroundRadius; + } + + public void setAroundRadius(OneOfintegerstring aroundRadius) { + this.aroundRadius = aroundRadius; + } + + public BaseSearchParams aroundPrecision(Integer aroundPrecision) { + this.aroundPrecision = aroundPrecision; + return this; + } + + /** + * Precision of geo search (in meters), to add grouping by geo location to the ranking formula. + * + * @return aroundPrecision + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Precision of geo search (in meters), to add grouping by geo location to the ranking" + + " formula." + ) + public Integer getAroundPrecision() { + return aroundPrecision; + } + + public void setAroundPrecision(Integer aroundPrecision) { + this.aroundPrecision = aroundPrecision; + } + + public BaseSearchParams minimumAroundRadius(Integer minimumAroundRadius) { + this.minimumAroundRadius = minimumAroundRadius; + return this; + } + + /** + * Minimum radius (in meters) used for a geo search when aroundRadius is not set. minimum: 1 + * + * @return minimumAroundRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum radius (in meters) used for a geo search when aroundRadius is not set." + ) + public Integer getMinimumAroundRadius() { + return minimumAroundRadius; + } + + public void setMinimumAroundRadius(Integer minimumAroundRadius) { + this.minimumAroundRadius = minimumAroundRadius; + } + + public BaseSearchParams insideBoundingBox( + List insideBoundingBox + ) { + this.insideBoundingBox = insideBoundingBox; + return this; + } + + public BaseSearchParams addInsideBoundingBoxItem( + BigDecimal insideBoundingBoxItem + ) { + if (this.insideBoundingBox == null) { + this.insideBoundingBox = new ArrayList<>(); + } + this.insideBoundingBox.add(insideBoundingBoxItem); + return this; + } + + /** + * Search inside a rectangular area (in geo coordinates). + * + * @return insideBoundingBox + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search inside a rectangular area (in geo coordinates)." + ) + public List getInsideBoundingBox() { + return insideBoundingBox; + } + + public void setInsideBoundingBox(List insideBoundingBox) { + this.insideBoundingBox = insideBoundingBox; + } + + public BaseSearchParams insidePolygon(List insidePolygon) { + this.insidePolygon = insidePolygon; + return this; + } + + public BaseSearchParams addInsidePolygonItem(BigDecimal insidePolygonItem) { + if (this.insidePolygon == null) { + this.insidePolygon = new ArrayList<>(); + } + this.insidePolygon.add(insidePolygonItem); + return this; + } + + /** + * Search inside a polygon (in geo coordinates). + * + * @return insidePolygon + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Search inside a polygon (in geo coordinates).") + public List getInsidePolygon() { + return insidePolygon; + } + + public void setInsidePolygon(List insidePolygon) { + this.insidePolygon = insidePolygon; + } + + public BaseSearchParams naturalLanguages(List naturalLanguages) { + this.naturalLanguages = naturalLanguages; + return this; + } + + public BaseSearchParams addNaturalLanguagesItem(String naturalLanguagesItem) { + if (this.naturalLanguages == null) { + this.naturalLanguages = new ArrayList<>(); + } + this.naturalLanguages.add(naturalLanguagesItem); + return this; + } + + /** + * This parameter changes the default values of certain parameters and settings that work best for + * a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, + * analyticsTags and ruleContexts. These parameters and settings work well together when the query + * is formatted in natural language instead of keywords, for example when your user performs a + * voice search. + * + * @return naturalLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "This parameter changes the default values of certain parameters and settings that work" + + " best for a natural language query, such as ignorePlurals, removeStopWords," + + " removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and" + + " settings work well together when the query is formatted in natural language" + + " instead of keywords, for example when your user performs a voice search." + ) + public List getNaturalLanguages() { + return naturalLanguages; + } + + public void setNaturalLanguages(List naturalLanguages) { + this.naturalLanguages = naturalLanguages; + } + + public BaseSearchParams ruleContexts(List ruleContexts) { + this.ruleContexts = ruleContexts; + return this; + } + + public BaseSearchParams addRuleContextsItem(String ruleContextsItem) { + if (this.ruleContexts == null) { + this.ruleContexts = new ArrayList<>(); + } + this.ruleContexts.add(ruleContextsItem); + return this; + } + + /** + * Enables contextual rules. + * + * @return ruleContexts + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables contextual rules.") + public List getRuleContexts() { + return ruleContexts; + } + + public void setRuleContexts(List ruleContexts) { + this.ruleContexts = ruleContexts; + } + + public BaseSearchParams personalizationImpact(Integer personalizationImpact) { + this.personalizationImpact = personalizationImpact; + return this; + } + + /** + * Define the impact of the Personalization feature. + * + * @return personalizationImpact + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Define the impact of the Personalization feature.") + public Integer getPersonalizationImpact() { + return personalizationImpact; + } + + public void setPersonalizationImpact(Integer personalizationImpact) { + this.personalizationImpact = personalizationImpact; + } + + public BaseSearchParams userToken(String userToken) { + this.userToken = userToken; + return this; + } + + /** + * Associates a certain user token with the current search. + * + * @return userToken + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Associates a certain user token with the current search." + ) + public String getUserToken() { + return userToken; + } + + public void setUserToken(String userToken) { + this.userToken = userToken; + } + + public BaseSearchParams getRankingInfo(Boolean getRankingInfo) { + this.getRankingInfo = getRankingInfo; + return this; + } + + /** + * Retrieve detailed ranking information. + * + * @return getRankingInfo + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Retrieve detailed ranking information.") + public Boolean getGetRankingInfo() { + return getRankingInfo; + } + + public void setGetRankingInfo(Boolean getRankingInfo) { + this.getRankingInfo = getRankingInfo; + } + + public BaseSearchParams clickAnalytics(Boolean clickAnalytics) { + this.clickAnalytics = clickAnalytics; + return this; + } + + /** + * Enable the Click Analytics feature. + * + * @return clickAnalytics + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enable the Click Analytics feature.") + public Boolean getClickAnalytics() { + return clickAnalytics; + } + + public void setClickAnalytics(Boolean clickAnalytics) { + this.clickAnalytics = clickAnalytics; + } + + public BaseSearchParams analytics(Boolean analytics) { + this.analytics = analytics; + return this; + } + + /** + * Whether the current query will be taken into account in the Analytics. + * + * @return analytics + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the current query will be taken into account in the Analytics." + ) + public Boolean getAnalytics() { + return analytics; + } + + public void setAnalytics(Boolean analytics) { + this.analytics = analytics; + } + + public BaseSearchParams analyticsTags(List analyticsTags) { + this.analyticsTags = analyticsTags; + return this; + } + + public BaseSearchParams addAnalyticsTagsItem(String analyticsTagsItem) { + if (this.analyticsTags == null) { + this.analyticsTags = new ArrayList<>(); + } + this.analyticsTags.add(analyticsTagsItem); + return this; + } + + /** + * List of tags to apply to the query for analytics purposes. + * + * @return analyticsTags + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of tags to apply to the query for analytics purposes." + ) + public List getAnalyticsTags() { + return analyticsTags; + } + + public void setAnalyticsTags(List analyticsTags) { + this.analyticsTags = analyticsTags; + } + + public BaseSearchParams percentileComputation(Boolean percentileComputation) { + this.percentileComputation = percentileComputation; + return this; + } + + /** + * Whether to include or exclude a query from the processing-time percentile computation. + * + * @return percentileComputation + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to include or exclude a query from the processing-time percentile computation." + ) + public Boolean getPercentileComputation() { + return percentileComputation; + } + + public void setPercentileComputation(Boolean percentileComputation) { + this.percentileComputation = percentileComputation; + } + + public BaseSearchParams enableABTest(Boolean enableABTest) { + this.enableABTest = enableABTest; + return this; + } + + /** + * Whether this search should participate in running AB tests. + * + * @return enableABTest + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether this search should participate in running AB tests." + ) + public Boolean getEnableABTest() { + return enableABTest; + } + + public void setEnableABTest(Boolean enableABTest) { + this.enableABTest = enableABTest; + } + + public BaseSearchParams enableReRanking(Boolean enableReRanking) { + this.enableReRanking = enableReRanking; + return this; + } + + /** + * Whether this search should use AI Re-Ranking. + * + * @return enableReRanking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether this search should use AI Re-Ranking.") + public Boolean getEnableReRanking() { + return enableReRanking; + } + + public void setEnableReRanking(Boolean enableReRanking) { + this.enableReRanking = enableReRanking; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseSearchParams baseSearchParams = (BaseSearchParams) o; + return ( + Objects.equals(this.query, baseSearchParams.query) && + Objects.equals(this.similarQuery, baseSearchParams.similarQuery) && + Objects.equals(this.filters, baseSearchParams.filters) && + Objects.equals(this.facetFilters, baseSearchParams.facetFilters) && + Objects.equals(this.optionalFilters, baseSearchParams.optionalFilters) && + Objects.equals(this.numericFilters, baseSearchParams.numericFilters) && + Objects.equals(this.tagFilters, baseSearchParams.tagFilters) && + Objects.equals( + this.sumOrFiltersScores, + baseSearchParams.sumOrFiltersScores + ) && + Objects.equals(this.facets, baseSearchParams.facets) && + Objects.equals( + this.maxValuesPerFacet, + baseSearchParams.maxValuesPerFacet + ) && + Objects.equals( + this.facetingAfterDistinct, + baseSearchParams.facetingAfterDistinct + ) && + Objects.equals( + this.sortFacetValuesBy, + baseSearchParams.sortFacetValuesBy + ) && + Objects.equals(this.page, baseSearchParams.page) && + Objects.equals(this.offset, baseSearchParams.offset) && + Objects.equals(this.length, baseSearchParams.length) && + Objects.equals(this.aroundLatLng, baseSearchParams.aroundLatLng) && + Objects.equals( + this.aroundLatLngViaIP, + baseSearchParams.aroundLatLngViaIP + ) && + Objects.equals(this.aroundRadius, baseSearchParams.aroundRadius) && + Objects.equals(this.aroundPrecision, baseSearchParams.aroundPrecision) && + Objects.equals( + this.minimumAroundRadius, + baseSearchParams.minimumAroundRadius + ) && + Objects.equals( + this.insideBoundingBox, + baseSearchParams.insideBoundingBox + ) && + Objects.equals(this.insidePolygon, baseSearchParams.insidePolygon) && + Objects.equals( + this.naturalLanguages, + baseSearchParams.naturalLanguages + ) && + Objects.equals(this.ruleContexts, baseSearchParams.ruleContexts) && + Objects.equals( + this.personalizationImpact, + baseSearchParams.personalizationImpact + ) && + Objects.equals(this.userToken, baseSearchParams.userToken) && + Objects.equals(this.getRankingInfo, baseSearchParams.getRankingInfo) && + Objects.equals(this.clickAnalytics, baseSearchParams.clickAnalytics) && + Objects.equals(this.analytics, baseSearchParams.analytics) && + Objects.equals(this.analyticsTags, baseSearchParams.analyticsTags) && + Objects.equals( + this.percentileComputation, + baseSearchParams.percentileComputation + ) && + Objects.equals(this.enableABTest, baseSearchParams.enableABTest) && + Objects.equals(this.enableReRanking, baseSearchParams.enableReRanking) + ); + } + + private static boolean equalsNullable( + JsonNullable a, + JsonNullable b + ) { + return ( + a == b || + ( + a != null && + b != null && + a.isPresent() && + b.isPresent() && + Objects.deepEquals(a.get(), b.get()) + ) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + query, + similarQuery, + filters, + facetFilters, + optionalFilters, + numericFilters, + tagFilters, + sumOrFiltersScores, + facets, + maxValuesPerFacet, + facetingAfterDistinct, + sortFacetValuesBy, + page, + offset, + length, + aroundLatLng, + aroundLatLngViaIP, + aroundRadius, + aroundPrecision, + minimumAroundRadius, + insideBoundingBox, + insidePolygon, + naturalLanguages, + ruleContexts, + personalizationImpact, + userToken, + getRankingInfo, + clickAnalytics, + analytics, + analyticsTags, + percentileComputation, + enableABTest, + enableReRanking + ); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] { a.get() }) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseSearchParams {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb + .append(" similarQuery: ") + .append(toIndentedString(similarQuery)) + .append("\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb + .append(" facetFilters: ") + .append(toIndentedString(facetFilters)) + .append("\n"); + sb + .append(" optionalFilters: ") + .append(toIndentedString(optionalFilters)) + .append("\n"); + sb + .append(" numericFilters: ") + .append(toIndentedString(numericFilters)) + .append("\n"); + sb + .append(" tagFilters: ") + .append(toIndentedString(tagFilters)) + .append("\n"); + sb + .append(" sumOrFiltersScores: ") + .append(toIndentedString(sumOrFiltersScores)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb + .append(" maxValuesPerFacet: ") + .append(toIndentedString(maxValuesPerFacet)) + .append("\n"); + sb + .append(" facetingAfterDistinct: ") + .append(toIndentedString(facetingAfterDistinct)) + .append("\n"); + sb + .append(" sortFacetValuesBy: ") + .append(toIndentedString(sortFacetValuesBy)) + .append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append(" length: ").append(toIndentedString(length)).append("\n"); + sb + .append(" aroundLatLng: ") + .append(toIndentedString(aroundLatLng)) + .append("\n"); + sb + .append(" aroundLatLngViaIP: ") + .append(toIndentedString(aroundLatLngViaIP)) + .append("\n"); + sb + .append(" aroundRadius: ") + .append(toIndentedString(aroundRadius)) + .append("\n"); + sb + .append(" aroundPrecision: ") + .append(toIndentedString(aroundPrecision)) + .append("\n"); + sb + .append(" minimumAroundRadius: ") + .append(toIndentedString(minimumAroundRadius)) + .append("\n"); + sb + .append(" insideBoundingBox: ") + .append(toIndentedString(insideBoundingBox)) + .append("\n"); + sb + .append(" insidePolygon: ") + .append(toIndentedString(insidePolygon)) + .append("\n"); + sb + .append(" naturalLanguages: ") + .append(toIndentedString(naturalLanguages)) + .append("\n"); + sb + .append(" ruleContexts: ") + .append(toIndentedString(ruleContexts)) + .append("\n"); + sb + .append(" personalizationImpact: ") + .append(toIndentedString(personalizationImpact)) + .append("\n"); + sb + .append(" userToken: ") + .append(toIndentedString(userToken)) + .append("\n"); + sb + .append(" getRankingInfo: ") + .append(toIndentedString(getRankingInfo)) + .append("\n"); + sb + .append(" clickAnalytics: ") + .append(toIndentedString(clickAnalytics)) + .append("\n"); + sb + .append(" analytics: ") + .append(toIndentedString(analytics)) + .append("\n"); + sb + .append(" analyticsTags: ") + .append(toIndentedString(analyticsTags)) + .append("\n"); + sb + .append(" percentileComputation: ") + .append(toIndentedString(percentileComputation)) + .append("\n"); + sb + .append(" enableABTest: ") + .append(toIndentedString(enableABTest)) + .append("\n"); + sb + .append(" enableReRanking: ") + .append(toIndentedString(enableReRanking)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponse.java new file mode 100644 index 00000000000..8a7d905271d --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponse.java @@ -0,0 +1,882 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** BaseSearchResponse */ +public class BaseSearchResponse { + + public static final String SERIALIZED_NAME_AB_TEST_I_D = "abTestID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_I_D) + private Integer abTestID; + + public static final String SERIALIZED_NAME_AB_TEST_VARIANT_I_D = + "abTestVariantID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_VARIANT_I_D) + private Integer abTestVariantID; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG = "aroundLatLng"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG) + private String aroundLatLng; + + public static final String SERIALIZED_NAME_AUTOMATIC_RADIUS = + "automaticRadius"; + + @SerializedName(SERIALIZED_NAME_AUTOMATIC_RADIUS) + private String automaticRadius; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT = + "exhaustiveFacetsCount"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT) + private Boolean exhaustiveFacetsCount; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_NB_HITS = + "exhaustiveNbHits"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_NB_HITS) + private Boolean exhaustiveNbHits; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_TYPO = "exhaustiveTypo"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_TYPO) + private Boolean exhaustiveTypo; + + public static final String SERIALIZED_NAME_FACETS = "facets"; + + @SerializedName(SERIALIZED_NAME_FACETS) + private Map> facets = null; + + public static final String SERIALIZED_NAME_FACETS_STATS = "facets_stats"; + + @SerializedName(SERIALIZED_NAME_FACETS_STATS) + private Map facetsStats = null; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_INDEX = "index"; + + @SerializedName(SERIALIZED_NAME_INDEX) + private String index; + + public static final String SERIALIZED_NAME_INDEX_USED = "indexUsed"; + + @SerializedName(SERIALIZED_NAME_INDEX_USED) + private String indexUsed; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_NB_HITS = "nbHits"; + + @SerializedName(SERIALIZED_NAME_NB_HITS) + private Integer nbHits; + + public static final String SERIALIZED_NAME_NB_PAGES = "nbPages"; + + @SerializedName(SERIALIZED_NAME_NB_PAGES) + private Integer nbPages; + + public static final String SERIALIZED_NAME_NB_SORTED_HITS = "nbSortedHits"; + + @SerializedName(SERIALIZED_NAME_NB_SORTED_HITS) + private Integer nbSortedHits; + + public static final String SERIALIZED_NAME_PAGE = "page"; + + @SerializedName(SERIALIZED_NAME_PAGE) + private Integer page = 0; + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params; + + public static final String SERIALIZED_NAME_PARSED_QUERY = "parsedQuery"; + + @SerializedName(SERIALIZED_NAME_PARSED_QUERY) + private String parsedQuery; + + public static final String SERIALIZED_NAME_PROCESSING_TIME_M_S = + "processingTimeMS"; + + @SerializedName(SERIALIZED_NAME_PROCESSING_TIME_M_S) + private Integer processingTimeMS; + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + public static final String SERIALIZED_NAME_QUERY_AFTER_REMOVAL = + "queryAfterRemoval"; + + @SerializedName(SERIALIZED_NAME_QUERY_AFTER_REMOVAL) + private String queryAfterRemoval; + + public static final String SERIALIZED_NAME_SERVER_USED = "serverUsed"; + + @SerializedName(SERIALIZED_NAME_SERVER_USED) + private String serverUsed; + + public static final String SERIALIZED_NAME_USER_DATA = "userData"; + + @SerializedName(SERIALIZED_NAME_USER_DATA) + private Map userData = null; + + public BaseSearchResponse abTestID(Integer abTestID) { + this.abTestID = abTestID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestID reports the ongoing A/B test + * ID. + * + * @return abTestID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestID reports the ongoing" + + " A/B test ID." + ) + public Integer getAbTestID() { + return abTestID; + } + + public void setAbTestID(Integer abTestID) { + this.abTestID = abTestID; + } + + public BaseSearchResponse abTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestVariantID reports the variant + * ID of the index used. + * + * @return abTestVariantID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestVariantID reports the" + + " variant ID of the index used." + ) + public Integer getAbTestVariantID() { + return abTestVariantID; + } + + public void setAbTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + } + + public BaseSearchResponse aroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + return this; + } + + /** + * The computed geo location. + * + * @return aroundLatLng + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The computed geo location.") + public String getAroundLatLng() { + return aroundLatLng; + } + + public void setAroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + } + + public BaseSearchResponse automaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + return this; + } + + /** + * The automatically computed radius. For legacy reasons, this parameter is a string and not an + * integer. + * + * @return automaticRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The automatically computed radius. For legacy reasons, this parameter is a string and" + + " not an integer." + ) + public String getAutomaticRadius() { + return automaticRadius; + } + + public void setAutomaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + } + + public BaseSearchResponse exhaustiveFacetsCount( + Boolean exhaustiveFacetsCount + ) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + return this; + } + + /** + * Whether the facet count is exhaustive or approximate. + * + * @return exhaustiveFacetsCount + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the facet count is exhaustive or approximate." + ) + public Boolean getExhaustiveFacetsCount() { + return exhaustiveFacetsCount; + } + + public void setExhaustiveFacetsCount(Boolean exhaustiveFacetsCount) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + } + + public BaseSearchResponse exhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + return this; + } + + /** + * Indicate if the nbHits count was exhaustive or approximate + * + * @return exhaustiveNbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the nbHits count was exhaustive or approximate" + ) + public Boolean getExhaustiveNbHits() { + return exhaustiveNbHits; + } + + public void setExhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + } + + public BaseSearchResponse exhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + return this; + } + + /** + * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * typo-tolerance is enabled) + * + * @return exhaustiveTypo + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the typo-tolerence search was exhaustive or approximate (only included when" + + " typo-tolerance is enabled)" + ) + public Boolean getExhaustiveTypo() { + return exhaustiveTypo; + } + + public void setExhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + } + + public BaseSearchResponse facets(Map> facets) { + this.facets = facets; + return this; + } + + public BaseSearchResponse putFacetsItem( + String key, + Map facetsItem + ) { + if (this.facets == null) { + this.facets = new HashMap<>(); + } + this.facets.put(key, facetsItem); + return this; + } + + /** + * A mapping of each facet name to the corresponding facet counts. + * + * @return facets + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "{\"category\":{\"food\":1,\"tech\":42}}", + value = "A mapping of each facet name to the corresponding facet counts." + ) + public Map> getFacets() { + return facets; + } + + public void setFacets(Map> facets) { + this.facets = facets; + } + + public BaseSearchResponse facetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + return this; + } + + public BaseSearchResponse putFacetsStatsItem( + String key, + BaseSearchResponseFacetsStats facetsStatsItem + ) { + if (this.facetsStats == null) { + this.facetsStats = new HashMap<>(); + } + this.facetsStats.put(key, facetsStatsItem); + return this; + } + + /** + * Statistics for numerical facets. + * + * @return facetsStats + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Statistics for numerical facets.") + public Map getFacetsStats() { + return facetsStats; + } + + public void setFacetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + } + + public BaseSearchResponse hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public BaseSearchResponse index(String index) { + this.index = index; + return this; + } + + /** + * Index name used for the query. + * + * @return index + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexName", + value = "Index name used for the query." + ) + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public BaseSearchResponse indexUsed(String indexUsed) { + this.indexUsed = indexUsed; + return this; + } + + /** + * Index name used for the query. In the case of an A/B test, the targeted index isn’t always the + * index used by the query. + * + * @return indexUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexNameAlt", + value = "Index name used for the query. In the case of an A/B test, the targeted index isn’t" + + " always the index used by the query." + ) + public String getIndexUsed() { + return indexUsed; + } + + public void setIndexUsed(String indexUsed) { + this.indexUsed = indexUsed; + } + + public BaseSearchResponse message(String message) { + this.message = message; + return this; + } + + /** + * Used to return warnings about the query. + * + * @return message + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Used to return warnings about the query.") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public BaseSearchResponse nbHits(Integer nbHits) { + this.nbHits = nbHits; + return this; + } + + /** + * Number of hits that the search query matched + * + * @return nbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Number of hits that the search query matched" + ) + public Integer getNbHits() { + return nbHits; + } + + public void setNbHits(Integer nbHits) { + this.nbHits = nbHits; + } + + public BaseSearchResponse nbPages(Integer nbPages) { + this.nbPages = nbPages; + return this; + } + + /** + * Number of pages available for the current query + * + * @return nbPages + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "1", + required = true, + value = "Number of pages available for the current query" + ) + public Integer getNbPages() { + return nbPages; + } + + public void setNbPages(Integer nbPages) { + this.nbPages = nbPages; + } + + public BaseSearchResponse nbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + return this; + } + + /** + * The number of hits selected and sorted by the relevant sort algorithm + * + * @return nbSortedHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "20", + value = "The number of hits selected and sorted by the relevant sort algorithm" + ) + public Integer getNbSortedHits() { + return nbSortedHits; + } + + public void setNbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + } + + public BaseSearchResponse page(Integer page) { + this.page = page; + return this; + } + + /** + * Specify the page to retrieve. + * + * @return page + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Specify the page to retrieve.") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public BaseSearchResponse params(String params) { + this.params = params; + return this; + } + + /** + * A url-encoded string of all search parameters. + * + * @return params + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "query=a&hitsPerPage=20", + required = true, + value = "A url-encoded string of all search parameters." + ) + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public BaseSearchResponse parsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + return this; + } + + /** + * The query string that will be searched, after normalization. + * + * @return parsedQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The query string that will be searched, after normalization." + ) + public String getParsedQuery() { + return parsedQuery; + } + + public void setParsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + } + + public BaseSearchResponse processingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + return this; + } + + /** + * Time the server took to process the request, in milliseconds. + * + * @return processingTimeMS + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Time the server took to process the request, in milliseconds." + ) + public Integer getProcessingTimeMS() { + return processingTimeMS; + } + + public void setProcessingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + } + + public BaseSearchResponse query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public BaseSearchResponse queryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + return this; + } + + /** + * A markup text indicating which parts of the original query have been removed in order to + * retrieve a non-empty result set. + * + * @return queryAfterRemoval + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A markup text indicating which parts of the original query have been removed in order to" + + " retrieve a non-empty result set." + ) + public String getQueryAfterRemoval() { + return queryAfterRemoval; + } + + public void setQueryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + } + + public BaseSearchResponse serverUsed(String serverUsed) { + this.serverUsed = serverUsed; + return this; + } + + /** + * Actual host name of the server that processed the request. + * + * @return serverUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Actual host name of the server that processed the request." + ) + public String getServerUsed() { + return serverUsed; + } + + public void setServerUsed(String serverUsed) { + this.serverUsed = serverUsed; + } + + public BaseSearchResponse userData(Map userData) { + this.userData = userData; + return this; + } + + public BaseSearchResponse putUserDataItem(String key, Object userDataItem) { + if (this.userData == null) { + this.userData = new HashMap<>(); + } + this.userData.put(key, userDataItem); + return this; + } + + /** + * Lets you store custom data in your indices. + * + * @return userData + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Lets you store custom data in your indices.") + public Map getUserData() { + return userData; + } + + public void setUserData(Map userData) { + this.userData = userData; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseSearchResponse baseSearchResponse = (BaseSearchResponse) o; + return ( + Objects.equals(this.abTestID, baseSearchResponse.abTestID) && + Objects.equals( + this.abTestVariantID, + baseSearchResponse.abTestVariantID + ) && + Objects.equals(this.aroundLatLng, baseSearchResponse.aroundLatLng) && + Objects.equals( + this.automaticRadius, + baseSearchResponse.automaticRadius + ) && + Objects.equals( + this.exhaustiveFacetsCount, + baseSearchResponse.exhaustiveFacetsCount + ) && + Objects.equals( + this.exhaustiveNbHits, + baseSearchResponse.exhaustiveNbHits + ) && + Objects.equals(this.exhaustiveTypo, baseSearchResponse.exhaustiveTypo) && + Objects.equals(this.facets, baseSearchResponse.facets) && + Objects.equals(this.facetsStats, baseSearchResponse.facetsStats) && + Objects.equals(this.hitsPerPage, baseSearchResponse.hitsPerPage) && + Objects.equals(this.index, baseSearchResponse.index) && + Objects.equals(this.indexUsed, baseSearchResponse.indexUsed) && + Objects.equals(this.message, baseSearchResponse.message) && + Objects.equals(this.nbHits, baseSearchResponse.nbHits) && + Objects.equals(this.nbPages, baseSearchResponse.nbPages) && + Objects.equals(this.nbSortedHits, baseSearchResponse.nbSortedHits) && + Objects.equals(this.page, baseSearchResponse.page) && + Objects.equals(this.params, baseSearchResponse.params) && + Objects.equals(this.parsedQuery, baseSearchResponse.parsedQuery) && + Objects.equals( + this.processingTimeMS, + baseSearchResponse.processingTimeMS + ) && + Objects.equals(this.query, baseSearchResponse.query) && + Objects.equals( + this.queryAfterRemoval, + baseSearchResponse.queryAfterRemoval + ) && + Objects.equals(this.serverUsed, baseSearchResponse.serverUsed) && + Objects.equals(this.userData, baseSearchResponse.userData) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + abTestID, + abTestVariantID, + aroundLatLng, + automaticRadius, + exhaustiveFacetsCount, + exhaustiveNbHits, + exhaustiveTypo, + facets, + facetsStats, + hitsPerPage, + index, + indexUsed, + message, + nbHits, + nbPages, + nbSortedHits, + page, + params, + parsedQuery, + processingTimeMS, + query, + queryAfterRemoval, + serverUsed, + userData + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseSearchResponse {\n"); + sb.append(" abTestID: ").append(toIndentedString(abTestID)).append("\n"); + sb + .append(" abTestVariantID: ") + .append(toIndentedString(abTestVariantID)) + .append("\n"); + sb + .append(" aroundLatLng: ") + .append(toIndentedString(aroundLatLng)) + .append("\n"); + sb + .append(" automaticRadius: ") + .append(toIndentedString(automaticRadius)) + .append("\n"); + sb + .append(" exhaustiveFacetsCount: ") + .append(toIndentedString(exhaustiveFacetsCount)) + .append("\n"); + sb + .append(" exhaustiveNbHits: ") + .append(toIndentedString(exhaustiveNbHits)) + .append("\n"); + sb + .append(" exhaustiveTypo: ") + .append(toIndentedString(exhaustiveTypo)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb + .append(" facetsStats: ") + .append(toIndentedString(facetsStats)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb + .append(" indexUsed: ") + .append(toIndentedString(indexUsed)) + .append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" nbHits: ").append(toIndentedString(nbHits)).append("\n"); + sb.append(" nbPages: ").append(toIndentedString(nbPages)).append("\n"); + sb + .append(" nbSortedHits: ") + .append(toIndentedString(nbSortedHits)) + .append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb + .append(" parsedQuery: ") + .append(toIndentedString(parsedQuery)) + .append("\n"); + sb + .append(" processingTimeMS: ") + .append(toIndentedString(processingTimeMS)) + .append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb + .append(" queryAfterRemoval: ") + .append(toIndentedString(queryAfterRemoval)) + .append("\n"); + sb + .append(" serverUsed: ") + .append(toIndentedString(serverUsed)) + .append("\n"); + sb.append(" userData: ").append(toIndentedString(userData)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponseFacetsStats.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponseFacetsStats.java new file mode 100644 index 00000000000..390f261989d --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BaseSearchResponseFacetsStats.java @@ -0,0 +1,153 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** BaseSearchResponseFacetsStats */ +public class BaseSearchResponseFacetsStats { + + public static final String SERIALIZED_NAME_MIN = "min"; + + @SerializedName(SERIALIZED_NAME_MIN) + private Integer min; + + public static final String SERIALIZED_NAME_MAX = "max"; + + @SerializedName(SERIALIZED_NAME_MAX) + private Integer max; + + public static final String SERIALIZED_NAME_AVG = "avg"; + + @SerializedName(SERIALIZED_NAME_AVG) + private Integer avg; + + public static final String SERIALIZED_NAME_SUM = "sum"; + + @SerializedName(SERIALIZED_NAME_SUM) + private Integer sum; + + public BaseSearchResponseFacetsStats min(Integer min) { + this.min = min; + return this; + } + + /** + * The minimum value in the result set. + * + * @return min + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The minimum value in the result set.") + public Integer getMin() { + return min; + } + + public void setMin(Integer min) { + this.min = min; + } + + public BaseSearchResponseFacetsStats max(Integer max) { + this.max = max; + return this; + } + + /** + * The maximum value in the result set. + * + * @return max + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The maximum value in the result set.") + public Integer getMax() { + return max; + } + + public void setMax(Integer max) { + this.max = max; + } + + public BaseSearchResponseFacetsStats avg(Integer avg) { + this.avg = avg; + return this; + } + + /** + * The average facet value in the result set. + * + * @return avg + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The average facet value in the result set.") + public Integer getAvg() { + return avg; + } + + public void setAvg(Integer avg) { + this.avg = avg; + } + + public BaseSearchResponseFacetsStats sum(Integer sum) { + this.sum = sum; + return this; + } + + /** + * The sum of all values in the result set. + * + * @return sum + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The sum of all values in the result set.") + public Integer getSum() { + return sum; + } + + public void setSum(Integer sum) { + this.sum = sum; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BaseSearchResponseFacetsStats baseSearchResponseFacetsStats = (BaseSearchResponseFacetsStats) o; + return ( + Objects.equals(this.min, baseSearchResponseFacetsStats.min) && + Objects.equals(this.max, baseSearchResponseFacetsStats.max) && + Objects.equals(this.avg, baseSearchResponseFacetsStats.avg) && + Objects.equals(this.sum, baseSearchResponseFacetsStats.sum) + ); + } + + @Override + public int hashCode() { + return Objects.hash(min, max, avg, sum); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BaseSearchResponseFacetsStats {\n"); + sb.append(" min: ").append(toIndentedString(min)).append("\n"); + sb.append(" max: ").append(toIndentedString(max)).append("\n"); + sb.append(" avg: ").append(toIndentedString(avg)).append("\n"); + sb.append(" sum: ").append(toIndentedString(sum)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchObject.java new file mode 100644 index 00000000000..e3f053211a0 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchObject.java @@ -0,0 +1,82 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** The `batch` requests. */ +@ApiModel(description = "The `batch` requests.") +public class BatchObject { + + public static final String SERIALIZED_NAME_REQUESTS = "requests"; + + @SerializedName(SERIALIZED_NAME_REQUESTS) + private List requests = null; + + public BatchObject requests(List requests) { + this.requests = requests; + return this; + } + + public BatchObject addRequestsItem(Operation requestsItem) { + if (this.requests == null) { + this.requests = new ArrayList<>(); + } + this.requests.add(requestsItem); + return this; + } + + /** + * Get requests + * + * @return requests + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public List getRequests() { + return requests; + } + + public void setRequests(List requests) { + this.requests = requests; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchObject batchObject = (BatchObject) o; + return Objects.equals(this.requests, batchObject.requests); + } + + @Override + public int hashCode() { + return Objects.hash(requests); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchObject {\n"); + sb.append(" requests: ").append(toIndentedString(requests)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchResponse.java new file mode 100644 index 00000000000..9d8a55c551a --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/BatchResponse.java @@ -0,0 +1,112 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** BatchResponse */ +public class BatchResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_OBJECT_I_DS = "objectIDs"; + + @SerializedName(SERIALIZED_NAME_OBJECT_I_DS) + private List objectIDs = null; + + public BatchResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "taskID of the indexing task to wait for.") + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public BatchResponse objectIDs(List objectIDs) { + this.objectIDs = objectIDs; + return this; + } + + public BatchResponse addObjectIDsItem(String objectIDsItem) { + if (this.objectIDs == null) { + this.objectIDs = new ArrayList<>(); + } + this.objectIDs.add(objectIDsItem); + return this; + } + + /** + * List of objectID. + * + * @return objectIDs + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of objectID.") + public List getObjectIDs() { + return objectIDs; + } + + public void setObjectIDs(List objectIDs) { + this.objectIDs = objectIDs; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + BatchResponse batchResponse = (BatchResponse) o; + return ( + Objects.equals(this.taskID, batchResponse.taskID) && + Objects.equals(this.objectIDs, batchResponse.objectIDs) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, objectIDs); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class BatchResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" objectIDs: ") + .append(toIndentedString(objectIDs)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ClearAllSynonymsResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ClearAllSynonymsResponse.java new file mode 100644 index 00000000000..f3f206367c6 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ClearAllSynonymsResponse.java @@ -0,0 +1,109 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** ClearAllSynonymsResponse */ +public class ClearAllSynonymsResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public ClearAllSynonymsResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "taskID of the indexing task to wait for." + ) + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public ClearAllSynonymsResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Date of last update (ISO-8601 format)." + ) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ClearAllSynonymsResponse clearAllSynonymsResponse = (ClearAllSynonymsResponse) o; + return ( + Objects.equals(this.taskID, clearAllSynonymsResponse.taskID) && + Objects.equals(this.updatedAt, clearAllSynonymsResponse.updatedAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ClearAllSynonymsResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteIndexResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteIndexResponse.java new file mode 100644 index 00000000000..28c6eba1257 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteIndexResponse.java @@ -0,0 +1,100 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** DeleteIndexResponse */ +public class DeleteIndexResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_DELETE_AT = "deleteAt"; + + @SerializedName(SERIALIZED_NAME_DELETE_AT) + private OffsetDateTime deleteAt; + + public DeleteIndexResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "taskID of the indexing task to wait for.") + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public DeleteIndexResponse deleteAt(OffsetDateTime deleteAt) { + this.deleteAt = deleteAt; + return this; + } + + /** + * Date of deletion (ISO-8601 format). + * + * @return deleteAt + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Date of deletion (ISO-8601 format).") + public OffsetDateTime getDeleteAt() { + return deleteAt; + } + + public void setDeleteAt(OffsetDateTime deleteAt) { + this.deleteAt = deleteAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteIndexResponse deleteIndexResponse = (DeleteIndexResponse) o; + return ( + Objects.equals(this.taskID, deleteIndexResponse.taskID) && + Objects.equals(this.deleteAt, deleteIndexResponse.deleteAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, deleteAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeleteIndexResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb.append(" deleteAt: ").append(toIndentedString(deleteAt)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteSynonymResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteSynonymResponse.java new file mode 100644 index 00000000000..f087b817349 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/DeleteSynonymResponse.java @@ -0,0 +1,109 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** DeleteSynonymResponse */ +public class DeleteSynonymResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_DELETED_AT = "deletedAt"; + + @SerializedName(SERIALIZED_NAME_DELETED_AT) + private OffsetDateTime deletedAt; + + public DeleteSynonymResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "taskID of the indexing task to wait for." + ) + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public DeleteSynonymResponse deletedAt(OffsetDateTime deletedAt) { + this.deletedAt = deletedAt; + return this; + } + + /** + * Date of deletion (ISO-8601 format). + * + * @return deletedAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Date of deletion (ISO-8601 format)." + ) + public OffsetDateTime getDeletedAt() { + return deletedAt; + } + + public void setDeletedAt(OffsetDateTime deletedAt) { + this.deletedAt = deletedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + DeleteSynonymResponse deleteSynonymResponse = (DeleteSynonymResponse) o; + return ( + Objects.equals(this.taskID, deleteSynonymResponse.taskID) && + Objects.equals(this.deletedAt, deleteSynonymResponse.deletedAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, deletedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DeleteSynonymResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" deletedAt: ") + .append(toIndentedString(deletedAt)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ErrorBase.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ErrorBase.java new file mode 100644 index 00000000000..95ad6123009 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ErrorBase.java @@ -0,0 +1,74 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.Objects; + +/** Error. */ +@ApiModel(description = "Error.") +public class ErrorBase extends HashMap { + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public ErrorBase message(String message) { + this.message = message; + return this; + } + + /** + * Get message + * + * @return message + */ + @javax.annotation.Nullable + @ApiModelProperty(example = "Invalid Application-Id or API-Key", value = "") + 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; + } + ErrorBase errorBase = (ErrorBase) o; + return Objects.equals(this.message, errorBase.message) && super.equals(o); + } + + @Override + public int hashCode() { + return Objects.hash(message, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorBase {\n"); + sb.append(" ").append(toIndentedString(super.toString())).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/HighlightResult.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/HighlightResult.java new file mode 100644 index 00000000000..7bb3d2dbbee --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/HighlightResult.java @@ -0,0 +1,239 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** HighlightResult */ +public class HighlightResult { + + public static final String SERIALIZED_NAME_VALUE = "value"; + + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + /** Indicates how well the attribute matched the search query. */ + @JsonAdapter(MatchLevelEnum.Adapter.class) + public enum MatchLevelEnum { + NONE("none"), + + PARTIAL("partial"), + + FULL("full"); + + private String value; + + MatchLevelEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MatchLevelEnum fromValue(String value) { + for (MatchLevelEnum b : MatchLevelEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final MatchLevelEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MatchLevelEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return MatchLevelEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_MATCH_LEVEL = "matchLevel"; + + @SerializedName(SERIALIZED_NAME_MATCH_LEVEL) + private MatchLevelEnum matchLevel; + + public static final String SERIALIZED_NAME_MATCHED_WORDS = "matchedWords"; + + @SerializedName(SERIALIZED_NAME_MATCHED_WORDS) + private List matchedWords = null; + + public static final String SERIALIZED_NAME_FULLY_HIGHLIGHTED = + "fullyHighlighted"; + + @SerializedName(SERIALIZED_NAME_FULLY_HIGHLIGHTED) + private Boolean fullyHighlighted; + + public HighlightResult value(String value) { + this.value = value; + return this; + } + + /** + * Markup text with occurrences highlighted. + * + * @return value + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "George Clooney", + value = "Markup text with occurrences highlighted." + ) + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public HighlightResult matchLevel(MatchLevelEnum matchLevel) { + this.matchLevel = matchLevel; + return this; + } + + /** + * Indicates how well the attribute matched the search query. + * + * @return matchLevel + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Indicates how well the attribute matched the search query." + ) + public MatchLevelEnum getMatchLevel() { + return matchLevel; + } + + public void setMatchLevel(MatchLevelEnum matchLevel) { + this.matchLevel = matchLevel; + } + + public HighlightResult matchedWords(List matchedWords) { + this.matchedWords = matchedWords; + return this; + } + + public HighlightResult addMatchedWordsItem(String matchedWordsItem) { + if (this.matchedWords == null) { + this.matchedWords = new ArrayList<>(); + } + this.matchedWords.add(matchedWordsItem); + return this; + } + + /** + * List of words from the query that matched the object. + * + * @return matchedWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of words from the query that matched the object." + ) + public List getMatchedWords() { + return matchedWords; + } + + public void setMatchedWords(List matchedWords) { + this.matchedWords = matchedWords; + } + + public HighlightResult fullyHighlighted(Boolean fullyHighlighted) { + this.fullyHighlighted = fullyHighlighted; + return this; + } + + /** + * Whether the entire attribute value is highlighted. + * + * @return fullyHighlighted + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the entire attribute value is highlighted." + ) + public Boolean getFullyHighlighted() { + return fullyHighlighted; + } + + public void setFullyHighlighted(Boolean fullyHighlighted) { + this.fullyHighlighted = fullyHighlighted; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HighlightResult highlightResult = (HighlightResult) o; + return ( + Objects.equals(this.value, highlightResult.value) && + Objects.equals(this.matchLevel, highlightResult.matchLevel) && + Objects.equals(this.matchedWords, highlightResult.matchedWords) && + Objects.equals(this.fullyHighlighted, highlightResult.fullyHighlighted) + ); + } + + @Override + public int hashCode() { + return Objects.hash(value, matchLevel, matchedWords, fullyHighlighted); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class HighlightResult {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb + .append(" matchLevel: ") + .append(toIndentedString(matchLevel)) + .append("\n"); + sb + .append(" matchedWords: ") + .append(toIndentedString(matchedWords)) + .append("\n"); + sb + .append(" fullyHighlighted: ") + .append(toIndentedString(fullyHighlighted)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Index.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Index.java new file mode 100644 index 00000000000..9f28608505e --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Index.java @@ -0,0 +1,410 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Index */ +public class Index { + + public static final String SERIALIZED_NAME_NAME = "name"; + + @SerializedName(SERIALIZED_NAME_NAME) + private String name; + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private OffsetDateTime createdAt; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public static final String SERIALIZED_NAME_ENTRIES = "entries"; + + @SerializedName(SERIALIZED_NAME_ENTRIES) + private Integer entries; + + public static final String SERIALIZED_NAME_DATA_SIZE = "dataSize"; + + @SerializedName(SERIALIZED_NAME_DATA_SIZE) + private Integer dataSize; + + public static final String SERIALIZED_NAME_FILE_SIZE = "fileSize"; + + @SerializedName(SERIALIZED_NAME_FILE_SIZE) + private Integer fileSize; + + public static final String SERIALIZED_NAME_LAST_BUILD_TIME_S = + "lastBuildTimeS"; + + @SerializedName(SERIALIZED_NAME_LAST_BUILD_TIME_S) + private Integer lastBuildTimeS; + + public static final String SERIALIZED_NAME_NUMBER_OF_PENDING_TASK = + "numberOfPendingTask"; + + @SerializedName(SERIALIZED_NAME_NUMBER_OF_PENDING_TASK) + private Integer numberOfPendingTask; + + public static final String SERIALIZED_NAME_PENDING_TASK = "pendingTask"; + + @SerializedName(SERIALIZED_NAME_PENDING_TASK) + private Boolean pendingTask; + + public static final String SERIALIZED_NAME_PRIMARY = "primary"; + + @SerializedName(SERIALIZED_NAME_PRIMARY) + private String primary; + + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + + @SerializedName(SERIALIZED_NAME_REPLICAS) + private List replicas = null; + + public Index name(String name) { + this.name = name; + return this; + } + + /** + * Index name. + * + * @return name + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Index name.") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Index createdAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Index creation date. An empty string means that the index has no records. + * + * @return createdAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Index creation date. An empty string means that the index has no records." + ) + public OffsetDateTime getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(OffsetDateTime createdAt) { + this.createdAt = createdAt; + } + + public Index updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Date of last update (ISO-8601 format)." + ) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public Index entries(Integer entries) { + this.entries = entries; + return this; + } + + /** + * Number of records contained in the index. + * + * @return entries + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Number of records contained in the index." + ) + public Integer getEntries() { + return entries; + } + + public void setEntries(Integer entries) { + this.entries = entries; + } + + public Index dataSize(Integer dataSize) { + this.dataSize = dataSize; + return this; + } + + /** + * Number of bytes of the index in minified format. + * + * @return dataSize + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Number of bytes of the index in minified format." + ) + public Integer getDataSize() { + return dataSize; + } + + public void setDataSize(Integer dataSize) { + this.dataSize = dataSize; + } + + public Index fileSize(Integer fileSize) { + this.fileSize = fileSize; + return this; + } + + /** + * Number of bytes of the index binary file. + * + * @return fileSize + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Number of bytes of the index binary file." + ) + public Integer getFileSize() { + return fileSize; + } + + public void setFileSize(Integer fileSize) { + this.fileSize = fileSize; + } + + public Index lastBuildTimeS(Integer lastBuildTimeS) { + this.lastBuildTimeS = lastBuildTimeS; + return this; + } + + /** + * Last build time + * + * @return lastBuildTimeS + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Last build time") + public Integer getLastBuildTimeS() { + return lastBuildTimeS; + } + + public void setLastBuildTimeS(Integer lastBuildTimeS) { + this.lastBuildTimeS = lastBuildTimeS; + } + + public Index numberOfPendingTask(Integer numberOfPendingTask) { + this.numberOfPendingTask = numberOfPendingTask; + return this; + } + + /** + * Number of pending indexing operations. This value is deprecated and should not be used. + * + * @return numberOfPendingTask + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Number of pending indexing operations. This value is deprecated and should not be used." + ) + public Integer getNumberOfPendingTask() { + return numberOfPendingTask; + } + + public void setNumberOfPendingTask(Integer numberOfPendingTask) { + this.numberOfPendingTask = numberOfPendingTask; + } + + public Index pendingTask(Boolean pendingTask) { + this.pendingTask = pendingTask; + return this; + } + + /** + * A boolean which says whether the index has pending tasks. This value is deprecated and should + * not be used. + * + * @return pendingTask + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "A boolean which says whether the index has pending tasks. This value is deprecated and" + + " should not be used." + ) + public Boolean getPendingTask() { + return pendingTask; + } + + public void setPendingTask(Boolean pendingTask) { + this.pendingTask = pendingTask; + } + + public Index primary(String primary) { + this.primary = primary; + return this; + } + + /** + * Only present if the index is a replica. Contains the name of the related primary index. + * + * @return primary + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Only present if the index is a replica. Contains the name of the related primary index." + ) + public String getPrimary() { + return primary; + } + + public void setPrimary(String primary) { + this.primary = primary; + } + + public Index replicas(List replicas) { + this.replicas = replicas; + return this; + } + + public Index addReplicasItem(String replicasItem) { + if (this.replicas == null) { + this.replicas = new ArrayList<>(); + } + this.replicas.add(replicasItem); + return this; + } + + /** + * Only present if the index is a primary index with replicas. Contains the names of all linked + * replicas. + * + * @return replicas + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Only present if the index is a primary index with replicas. Contains the names of all" + + " linked replicas." + ) + public List getReplicas() { + return replicas; + } + + public void setReplicas(List replicas) { + this.replicas = replicas; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Index index = (Index) o; + return ( + Objects.equals(this.name, index.name) && + Objects.equals(this.createdAt, index.createdAt) && + Objects.equals(this.updatedAt, index.updatedAt) && + Objects.equals(this.entries, index.entries) && + Objects.equals(this.dataSize, index.dataSize) && + Objects.equals(this.fileSize, index.fileSize) && + Objects.equals(this.lastBuildTimeS, index.lastBuildTimeS) && + Objects.equals(this.numberOfPendingTask, index.numberOfPendingTask) && + Objects.equals(this.pendingTask, index.pendingTask) && + Objects.equals(this.primary, index.primary) && + Objects.equals(this.replicas, index.replicas) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + name, + createdAt, + updatedAt, + entries, + dataSize, + fileSize, + lastBuildTimeS, + numberOfPendingTask, + pendingTask, + primary, + replicas + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Index {\n"); + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb + .append(" createdAt: ") + .append(toIndentedString(createdAt)) + .append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .append("\n"); + sb.append(" entries: ").append(toIndentedString(entries)).append("\n"); + sb.append(" dataSize: ").append(toIndentedString(dataSize)).append("\n"); + sb.append(" fileSize: ").append(toIndentedString(fileSize)).append("\n"); + sb + .append(" lastBuildTimeS: ") + .append(toIndentedString(lastBuildTimeS)) + .append("\n"); + sb + .append(" numberOfPendingTask: ") + .append(toIndentedString(numberOfPendingTask)) + .append("\n"); + sb + .append(" pendingTask: ") + .append(toIndentedString(pendingTask)) + .append("\n"); + sb.append(" primary: ").append(toIndentedString(primary)).append("\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java new file mode 100644 index 00000000000..5b043ad11c5 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettings.java @@ -0,0 +1,2654 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** The Algolia index settings. */ +@ApiModel(description = "The Algolia index settings.") +public class IndexSettings { + + public static final String SERIALIZED_NAME_REPLICAS = "replicas"; + + @SerializedName(SERIALIZED_NAME_REPLICAS) + private List replicas = null; + + public static final String SERIALIZED_NAME_PAGINATION_LIMITED_TO = + "paginationLimitedTo"; + + @SerializedName(SERIALIZED_NAME_PAGINATION_LIMITED_TO) + private Integer paginationLimitedTo = 1000; + + public static final String SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_WORDS = + "disableTypoToleranceOnWords"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_WORDS) + private List disableTypoToleranceOnWords = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_TRANSLITERATE = + "attributesToTransliterate"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_TRANSLITERATE) + private List attributesToTransliterate = null; + + public static final String SERIALIZED_NAME_CAMEL_CASE_ATTRIBUTES = + "camelCaseAttributes"; + + @SerializedName(SERIALIZED_NAME_CAMEL_CASE_ATTRIBUTES) + private List camelCaseAttributes = null; + + public static final String SERIALIZED_NAME_DECOMPOUNDED_ATTRIBUTES = + "decompoundedAttributes"; + + @SerializedName(SERIALIZED_NAME_DECOMPOUNDED_ATTRIBUTES) + private Map decompoundedAttributes = null; + + public static final String SERIALIZED_NAME_INDEX_LANGUAGES = "indexLanguages"; + + @SerializedName(SERIALIZED_NAME_INDEX_LANGUAGES) + private List indexLanguages = null; + + public static final String SERIALIZED_NAME_FILTER_PROMOTES = "filterPromotes"; + + @SerializedName(SERIALIZED_NAME_FILTER_PROMOTES) + private Boolean filterPromotes = false; + + public static final String SERIALIZED_NAME_DISABLE_PREFIX_ON_ATTRIBUTES = + "disablePrefixOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_PREFIX_ON_ATTRIBUTES) + private List disablePrefixOnAttributes = null; + + public static final String SERIALIZED_NAME_ALLOW_COMPRESSION_OF_INTEGER_ARRAY = + "allowCompressionOfIntegerArray"; + + @SerializedName(SERIALIZED_NAME_ALLOW_COMPRESSION_OF_INTEGER_ARRAY) + private Boolean allowCompressionOfIntegerArray = false; + + public static final String SERIALIZED_NAME_NUMERIC_ATTRIBUTES_FOR_FILTERING = + "numericAttributesForFiltering"; + + @SerializedName(SERIALIZED_NAME_NUMERIC_ATTRIBUTES_FOR_FILTERING) + private List numericAttributesForFiltering = null; + + public static final String SERIALIZED_NAME_USER_DATA = "userData"; + + @SerializedName(SERIALIZED_NAME_USER_DATA) + private Map userData = null; + + public static final String SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES = + "searchableAttributes"; + + @SerializedName(SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES) + private List searchableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING = + "attributesForFaceting"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING) + private List attributesForFaceting = null; + + public static final String SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES = + "unretrievableAttributes"; + + @SerializedName(SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES) + private List unretrievableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE = + "attributesToRetrieve"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE) + private List attributesToRetrieve = null; + + public static final String SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES = + "restrictSearchableAttributes"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES) + private List restrictSearchableAttributes = null; + + public static final String SERIALIZED_NAME_RANKING = "ranking"; + + @SerializedName(SERIALIZED_NAME_RANKING) + private List ranking = null; + + public static final String SERIALIZED_NAME_CUSTOM_RANKING = "customRanking"; + + @SerializedName(SERIALIZED_NAME_CUSTOM_RANKING) + private List customRanking = null; + + public static final String SERIALIZED_NAME_RELEVANCY_STRICTNESS = + "relevancyStrictness"; + + @SerializedName(SERIALIZED_NAME_RELEVANCY_STRICTNESS) + private Integer relevancyStrictness = 100; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT = + "attributesToHighlight"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT) + private List attributesToHighlight = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET = + "attributesToSnippet"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET) + private List attributesToSnippet = null; + + public static final String SERIALIZED_NAME_HIGHLIGHT_PRE_TAG = + "highlightPreTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_PRE_TAG) + private String highlightPreTag = ""; + + public static final String SERIALIZED_NAME_HIGHLIGHT_POST_TAG = + "highlightPostTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_POST_TAG) + private String highlightPostTag = ""; + + public static final String SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT = + "snippetEllipsisText"; + + @SerializedName(SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT) + private String snippetEllipsisText = "…"; + + public static final String SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS = + "restrictHighlightAndSnippetArrays"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS) + private Boolean restrictHighlightAndSnippetArrays = false; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO = + "minWordSizefor1Typo"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO) + private Integer minWordSizefor1Typo = 4; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS = + "minWordSizefor2Typos"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS) + private Integer minWordSizefor2Typos = 8; + + /** Controls whether typo tolerance is enabled and how it is applied. */ + @JsonAdapter(TypoToleranceEnum.Adapter.class) + public enum TypoToleranceEnum { + TRUE("true"), + + FALSE("false"), + + MIN("min"), + + STRICT("strict"); + + private String value; + + TypoToleranceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypoToleranceEnum fromValue(String value) { + for (TypoToleranceEnum b : TypoToleranceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final TypoToleranceEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypoToleranceEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return TypoToleranceEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPO_TOLERANCE = "typoTolerance"; + + @SerializedName(SERIALIZED_NAME_TYPO_TOLERANCE) + private TypoToleranceEnum typoTolerance = TypoToleranceEnum.TRUE; + + public static final String SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS = + "allowTyposOnNumericTokens"; + + @SerializedName(SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS) + private Boolean allowTyposOnNumericTokens = true; + + public static final String SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES = + "disableTypoToleranceOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES) + private List disableTypoToleranceOnAttributes = null; + + public static final String SERIALIZED_NAME_SEPARATORS_TO_INDEX = + "separatorsToIndex"; + + @SerializedName(SERIALIZED_NAME_SEPARATORS_TO_INDEX) + private String separatorsToIndex = ""; + + public static final String SERIALIZED_NAME_IGNORE_PLURALS = "ignorePlurals"; + + @SerializedName(SERIALIZED_NAME_IGNORE_PLURALS) + private String ignorePlurals = "false"; + + public static final String SERIALIZED_NAME_REMOVE_STOP_WORDS = + "removeStopWords"; + + @SerializedName(SERIALIZED_NAME_REMOVE_STOP_WORDS) + private String removeStopWords = "false"; + + public static final String SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS = + "keepDiacriticsOnCharacters"; + + @SerializedName(SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS) + private String keepDiacriticsOnCharacters = ""; + + public static final String SERIALIZED_NAME_QUERY_LANGUAGES = "queryLanguages"; + + @SerializedName(SERIALIZED_NAME_QUERY_LANGUAGES) + private List queryLanguages = null; + + public static final String SERIALIZED_NAME_DECOMPOUND_QUERY = + "decompoundQuery"; + + @SerializedName(SERIALIZED_NAME_DECOMPOUND_QUERY) + private Boolean decompoundQuery = true; + + public static final String SERIALIZED_NAME_ENABLE_RULES = "enableRules"; + + @SerializedName(SERIALIZED_NAME_ENABLE_RULES) + private Boolean enableRules = true; + + public static final String SERIALIZED_NAME_ENABLE_PERSONALIZATION = + "enablePersonalization"; + + @SerializedName(SERIALIZED_NAME_ENABLE_PERSONALIZATION) + private Boolean enablePersonalization = false; + + /** Controls if and how query words are interpreted as prefixes. */ + @JsonAdapter(QueryTypeEnum.Adapter.class) + public enum QueryTypeEnum { + PREFIXLAST("prefixLast"), + + PREFIXALL("prefixAll"), + + PREFIXNONE("prefixNone"); + + private String value; + + QueryTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static QueryTypeEnum fromValue(String value) { + for (QueryTypeEnum b : QueryTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final QueryTypeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public QueryTypeEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return QueryTypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_QUERY_TYPE = "queryType"; + + @SerializedName(SERIALIZED_NAME_QUERY_TYPE) + private QueryTypeEnum queryType = QueryTypeEnum.PREFIXLAST; + + /** Selects a strategy to remove words from the query when it doesn’t match any hits. */ + @JsonAdapter(RemoveWordsIfNoResultsEnum.Adapter.class) + public enum RemoveWordsIfNoResultsEnum { + NONE("none"), + + LASTWORDS("lastWords"), + + FIRSTWORDS("firstWords"), + + ALLOPTIONAL("allOptional"); + + private String value; + + RemoveWordsIfNoResultsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RemoveWordsIfNoResultsEnum fromValue(String value) { + for (RemoveWordsIfNoResultsEnum b : RemoveWordsIfNoResultsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final RemoveWordsIfNoResultsEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RemoveWordsIfNoResultsEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return RemoveWordsIfNoResultsEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS = + "removeWordsIfNoResults"; + + @SerializedName(SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS) + private RemoveWordsIfNoResultsEnum removeWordsIfNoResults = + RemoveWordsIfNoResultsEnum.NONE; + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX = "advancedSyntax"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX) + private Boolean advancedSyntax = false; + + public static final String SERIALIZED_NAME_OPTIONAL_WORDS = "optionalWords"; + + @SerializedName(SERIALIZED_NAME_OPTIONAL_WORDS) + private List optionalWords = null; + + public static final String SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES = + "disableExactOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES) + private List disableExactOnAttributes = null; + + /** Controls how the exact ranking criterion is computed when the query contains only one word. */ + @JsonAdapter(ExactOnSingleWordQueryEnum.Adapter.class) + public enum ExactOnSingleWordQueryEnum { + ATTRIBUTE("attribute"), + + NONE("none"), + + WORD("word"); + + private String value; + + ExactOnSingleWordQueryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ExactOnSingleWordQueryEnum fromValue(String value) { + for (ExactOnSingleWordQueryEnum b : ExactOnSingleWordQueryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final ExactOnSingleWordQueryEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ExactOnSingleWordQueryEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return ExactOnSingleWordQueryEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY = + "exactOnSingleWordQuery"; + + @SerializedName(SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY) + private ExactOnSingleWordQueryEnum exactOnSingleWordQuery = + ExactOnSingleWordQueryEnum.ATTRIBUTE; + + /** Gets or Sets alternativesAsExact */ + @JsonAdapter(AlternativesAsExactEnum.Adapter.class) + public enum AlternativesAsExactEnum { + IGNOREPLURALS("ignorePlurals"), + + SINGLEWORDSYNONYM("singleWordSynonym"), + + MULTIWORDSSYNONYM("multiWordsSynonym"); + + private String value; + + AlternativesAsExactEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AlternativesAsExactEnum fromValue(String value) { + for (AlternativesAsExactEnum b : AlternativesAsExactEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AlternativesAsExactEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AlternativesAsExactEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AlternativesAsExactEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ALTERNATIVES_AS_EXACT = + "alternativesAsExact"; + + @SerializedName(SERIALIZED_NAME_ALTERNATIVES_AS_EXACT) + private List alternativesAsExact = null; + + /** Gets or Sets advancedSyntaxFeatures */ + @JsonAdapter(AdvancedSyntaxFeaturesEnum.Adapter.class) + public enum AdvancedSyntaxFeaturesEnum { + EXACTPHRASE("exactPhrase"), + + EXCLUDEWORDS("excludeWords"); + + private String value; + + AdvancedSyntaxFeaturesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AdvancedSyntaxFeaturesEnum fromValue(String value) { + for (AdvancedSyntaxFeaturesEnum b : AdvancedSyntaxFeaturesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AdvancedSyntaxFeaturesEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AdvancedSyntaxFeaturesEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AdvancedSyntaxFeaturesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES = + "advancedSyntaxFeatures"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES) + private List advancedSyntaxFeatures = null; + + public static final String SERIALIZED_NAME_DISTINCT = "distinct"; + + @SerializedName(SERIALIZED_NAME_DISTINCT) + private Integer distinct = 0; + + public static final String SERIALIZED_NAME_SYNONYMS = "synonyms"; + + @SerializedName(SERIALIZED_NAME_SYNONYMS) + private Boolean synonyms = true; + + public static final String SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT = + "replaceSynonymsInHighlight"; + + @SerializedName(SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT) + private Boolean replaceSynonymsInHighlight = false; + + public static final String SERIALIZED_NAME_MIN_PROXIMITY = "minProximity"; + + @SerializedName(SERIALIZED_NAME_MIN_PROXIMITY) + private Integer minProximity = 1; + + public static final String SERIALIZED_NAME_RESPONSE_FIELDS = "responseFields"; + + @SerializedName(SERIALIZED_NAME_RESPONSE_FIELDS) + private List responseFields = null; + + public static final String SERIALIZED_NAME_MAX_FACET_HITS = "maxFacetHits"; + + @SerializedName(SERIALIZED_NAME_MAX_FACET_HITS) + private Integer maxFacetHits = 10; + + public static final String SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY = + "attributeCriteriaComputedByMinProximity"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY) + private Boolean attributeCriteriaComputedByMinProximity = false; + + public static final String SERIALIZED_NAME_RENDERING_CONTENT = + "renderingContent"; + + @SerializedName(SERIALIZED_NAME_RENDERING_CONTENT) + private Object renderingContent = new Object(); + + public IndexSettings replicas(List replicas) { + this.replicas = replicas; + return this; + } + + public IndexSettings addReplicasItem(String replicasItem) { + if (this.replicas == null) { + this.replicas = new ArrayList<>(); + } + this.replicas.add(replicasItem); + return this; + } + + /** + * Creates replicas, exact copies of an index. + * + * @return replicas + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Creates replicas, exact copies of an index.") + public List getReplicas() { + return replicas; + } + + public void setReplicas(List replicas) { + this.replicas = replicas; + } + + public IndexSettings paginationLimitedTo(Integer paginationLimitedTo) { + this.paginationLimitedTo = paginationLimitedTo; + return this; + } + + /** + * Set the maximum number of hits accessible via pagination. + * + * @return paginationLimitedTo + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Set the maximum number of hits accessible via pagination." + ) + public Integer getPaginationLimitedTo() { + return paginationLimitedTo; + } + + public void setPaginationLimitedTo(Integer paginationLimitedTo) { + this.paginationLimitedTo = paginationLimitedTo; + } + + public IndexSettings disableTypoToleranceOnWords( + List disableTypoToleranceOnWords + ) { + this.disableTypoToleranceOnWords = disableTypoToleranceOnWords; + return this; + } + + public IndexSettings addDisableTypoToleranceOnWordsItem( + String disableTypoToleranceOnWordsItem + ) { + if (this.disableTypoToleranceOnWords == null) { + this.disableTypoToleranceOnWords = new ArrayList<>(); + } + this.disableTypoToleranceOnWords.add(disableTypoToleranceOnWordsItem); + return this; + } + + /** + * A list of words for which you want to turn off typo tolerance. + * + * @return disableTypoToleranceOnWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A list of words for which you want to turn off typo tolerance." + ) + public List getDisableTypoToleranceOnWords() { + return disableTypoToleranceOnWords; + } + + public void setDisableTypoToleranceOnWords( + List disableTypoToleranceOnWords + ) { + this.disableTypoToleranceOnWords = disableTypoToleranceOnWords; + } + + public IndexSettings attributesToTransliterate( + List attributesToTransliterate + ) { + this.attributesToTransliterate = attributesToTransliterate; + return this; + } + + public IndexSettings addAttributesToTransliterateItem( + String attributesToTransliterateItem + ) { + if (this.attributesToTransliterate == null) { + this.attributesToTransliterate = new ArrayList<>(); + } + this.attributesToTransliterate.add(attributesToTransliterateItem); + return this; + } + + /** + * Specify on which attributes to apply transliteration. + * + * @return attributesToTransliterate + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Specify on which attributes to apply transliteration." + ) + public List getAttributesToTransliterate() { + return attributesToTransliterate; + } + + public void setAttributesToTransliterate( + List attributesToTransliterate + ) { + this.attributesToTransliterate = attributesToTransliterate; + } + + public IndexSettings camelCaseAttributes(List camelCaseAttributes) { + this.camelCaseAttributes = camelCaseAttributes; + return this; + } + + public IndexSettings addCamelCaseAttributesItem( + String camelCaseAttributesItem + ) { + if (this.camelCaseAttributes == null) { + this.camelCaseAttributes = new ArrayList<>(); + } + this.camelCaseAttributes.add(camelCaseAttributesItem); + return this; + } + + /** + * List of attributes on which to do a decomposition of camel case words. + * + * @return camelCaseAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which to do a decomposition of camel case words." + ) + public List getCamelCaseAttributes() { + return camelCaseAttributes; + } + + public void setCamelCaseAttributes(List camelCaseAttributes) { + this.camelCaseAttributes = camelCaseAttributes; + } + + public IndexSettings decompoundedAttributes( + Map decompoundedAttributes + ) { + this.decompoundedAttributes = decompoundedAttributes; + return this; + } + + public IndexSettings putDecompoundedAttributesItem( + String key, + Object decompoundedAttributesItem + ) { + if (this.decompoundedAttributes == null) { + this.decompoundedAttributes = new HashMap<>(); + } + this.decompoundedAttributes.put(key, decompoundedAttributesItem); + return this; + } + + /** + * Specify on which attributes in your index Algolia should apply word segmentation, also known as + * decompounding. + * + * @return decompoundedAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Specify on which attributes in your index Algolia should apply word segmentation, also" + + " known as decompounding." + ) + public Map getDecompoundedAttributes() { + return decompoundedAttributes; + } + + public void setDecompoundedAttributes( + Map decompoundedAttributes + ) { + this.decompoundedAttributes = decompoundedAttributes; + } + + public IndexSettings indexLanguages(List indexLanguages) { + this.indexLanguages = indexLanguages; + return this; + } + + public IndexSettings addIndexLanguagesItem(String indexLanguagesItem) { + if (this.indexLanguages == null) { + this.indexLanguages = new ArrayList<>(); + } + this.indexLanguages.add(indexLanguagesItem); + return this; + } + + /** + * Sets the languages at the index level for language-specific processing such as tokenization and + * normalization. + * + * @return indexLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Sets the languages at the index level for language-specific processing such as" + + " tokenization and normalization." + ) + public List getIndexLanguages() { + return indexLanguages; + } + + public void setIndexLanguages(List indexLanguages) { + this.indexLanguages = indexLanguages; + } + + public IndexSettings filterPromotes(Boolean filterPromotes) { + this.filterPromotes = filterPromotes; + return this; + } + + /** + * Whether promoted results should match the filters of the current search, except for geographic + * filters. + * + * @return filterPromotes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether promoted results should match the filters of the current search, except for" + + " geographic filters." + ) + public Boolean getFilterPromotes() { + return filterPromotes; + } + + public void setFilterPromotes(Boolean filterPromotes) { + this.filterPromotes = filterPromotes; + } + + public IndexSettings disablePrefixOnAttributes( + List disablePrefixOnAttributes + ) { + this.disablePrefixOnAttributes = disablePrefixOnAttributes; + return this; + } + + public IndexSettings addDisablePrefixOnAttributesItem( + String disablePrefixOnAttributesItem + ) { + if (this.disablePrefixOnAttributes == null) { + this.disablePrefixOnAttributes = new ArrayList<>(); + } + this.disablePrefixOnAttributes.add(disablePrefixOnAttributesItem); + return this; + } + + /** + * List of attributes on which you want to disable prefix matching. + * + * @return disablePrefixOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable prefix matching." + ) + public List getDisablePrefixOnAttributes() { + return disablePrefixOnAttributes; + } + + public void setDisablePrefixOnAttributes( + List disablePrefixOnAttributes + ) { + this.disablePrefixOnAttributes = disablePrefixOnAttributes; + } + + public IndexSettings allowCompressionOfIntegerArray( + Boolean allowCompressionOfIntegerArray + ) { + this.allowCompressionOfIntegerArray = allowCompressionOfIntegerArray; + return this; + } + + /** + * Enables compression of large integer arrays. + * + * @return allowCompressionOfIntegerArray + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables compression of large integer arrays.") + public Boolean getAllowCompressionOfIntegerArray() { + return allowCompressionOfIntegerArray; + } + + public void setAllowCompressionOfIntegerArray( + Boolean allowCompressionOfIntegerArray + ) { + this.allowCompressionOfIntegerArray = allowCompressionOfIntegerArray; + } + + public IndexSettings numericAttributesForFiltering( + List numericAttributesForFiltering + ) { + this.numericAttributesForFiltering = numericAttributesForFiltering; + return this; + } + + public IndexSettings addNumericAttributesForFilteringItem( + String numericAttributesForFilteringItem + ) { + if (this.numericAttributesForFiltering == null) { + this.numericAttributesForFiltering = new ArrayList<>(); + } + this.numericAttributesForFiltering.add(numericAttributesForFilteringItem); + return this; + } + + /** + * List of numeric attributes that can be used as numerical filters. + * + * @return numericAttributesForFiltering + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of numeric attributes that can be used as numerical filters." + ) + public List getNumericAttributesForFiltering() { + return numericAttributesForFiltering; + } + + public void setNumericAttributesForFiltering( + List numericAttributesForFiltering + ) { + this.numericAttributesForFiltering = numericAttributesForFiltering; + } + + public IndexSettings userData(Map userData) { + this.userData = userData; + return this; + } + + public IndexSettings putUserDataItem(String key, Object userDataItem) { + if (this.userData == null) { + this.userData = new HashMap<>(); + } + this.userData.put(key, userDataItem); + return this; + } + + /** + * Lets you store custom data in your indices. + * + * @return userData + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Lets you store custom data in your indices.") + public Map getUserData() { + return userData; + } + + public void setUserData(Map userData) { + this.userData = userData; + } + + public IndexSettings searchableAttributes(List searchableAttributes) { + this.searchableAttributes = searchableAttributes; + return this; + } + + public IndexSettings addSearchableAttributesItem( + String searchableAttributesItem + ) { + if (this.searchableAttributes == null) { + this.searchableAttributes = new ArrayList<>(); + } + this.searchableAttributes.add(searchableAttributesItem); + return this; + } + + /** + * The complete list of attributes used for searching. + * + * @return searchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes used for searching." + ) + public List getSearchableAttributes() { + return searchableAttributes; + } + + public void setSearchableAttributes(List searchableAttributes) { + this.searchableAttributes = searchableAttributes; + } + + public IndexSettings attributesForFaceting( + List attributesForFaceting + ) { + this.attributesForFaceting = attributesForFaceting; + return this; + } + + public IndexSettings addAttributesForFacetingItem( + String attributesForFacetingItem + ) { + if (this.attributesForFaceting == null) { + this.attributesForFaceting = new ArrayList<>(); + } + this.attributesForFaceting.add(attributesForFacetingItem); + return this; + } + + /** + * The complete list of attributes that will be used for faceting. + * + * @return attributesForFaceting + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes that will be used for faceting." + ) + public List getAttributesForFaceting() { + return attributesForFaceting; + } + + public void setAttributesForFaceting(List attributesForFaceting) { + this.attributesForFaceting = attributesForFaceting; + } + + public IndexSettings unretrievableAttributes( + List unretrievableAttributes + ) { + this.unretrievableAttributes = unretrievableAttributes; + return this; + } + + public IndexSettings addUnretrievableAttributesItem( + String unretrievableAttributesItem + ) { + if (this.unretrievableAttributes == null) { + this.unretrievableAttributes = new ArrayList<>(); + } + this.unretrievableAttributes.add(unretrievableAttributesItem); + return this; + } + + /** + * List of attributes that can’t be retrieved at query time. + * + * @return unretrievableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes that can’t be retrieved at query time." + ) + public List getUnretrievableAttributes() { + return unretrievableAttributes; + } + + public void setUnretrievableAttributes(List unretrievableAttributes) { + this.unretrievableAttributes = unretrievableAttributes; + } + + public IndexSettings attributesToRetrieve(List attributesToRetrieve) { + this.attributesToRetrieve = attributesToRetrieve; + return this; + } + + public IndexSettings addAttributesToRetrieveItem( + String attributesToRetrieveItem + ) { + if (this.attributesToRetrieve == null) { + this.attributesToRetrieve = new ArrayList<>(); + } + this.attributesToRetrieve.add(attributesToRetrieveItem); + return this; + } + + /** + * This parameter controls which attributes to retrieve and which not to retrieve. + * + * @return attributesToRetrieve + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "This parameter controls which attributes to retrieve and which not to retrieve." + ) + public List getAttributesToRetrieve() { + return attributesToRetrieve; + } + + public void setAttributesToRetrieve(List attributesToRetrieve) { + this.attributesToRetrieve = attributesToRetrieve; + } + + public IndexSettings restrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + return this; + } + + public IndexSettings addRestrictSearchableAttributesItem( + String restrictSearchableAttributesItem + ) { + if (this.restrictSearchableAttributes == null) { + this.restrictSearchableAttributes = new ArrayList<>(); + } + this.restrictSearchableAttributes.add(restrictSearchableAttributesItem); + return this; + } + + /** + * Restricts a given query to look in only a subset of your searchable attributes. + * + * @return restrictSearchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restricts a given query to look in only a subset of your searchable attributes." + ) + public List getRestrictSearchableAttributes() { + return restrictSearchableAttributes; + } + + public void setRestrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + } + + public IndexSettings ranking(List ranking) { + this.ranking = ranking; + return this; + } + + public IndexSettings addRankingItem(String rankingItem) { + if (this.ranking == null) { + this.ranking = new ArrayList<>(); + } + this.ranking.add(rankingItem); + return this; + } + + /** + * Controls how Algolia should sort your results. + * + * @return ranking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Controls how Algolia should sort your results.") + public List getRanking() { + return ranking; + } + + public void setRanking(List ranking) { + this.ranking = ranking; + } + + public IndexSettings customRanking(List customRanking) { + this.customRanking = customRanking; + return this; + } + + public IndexSettings addCustomRankingItem(String customRankingItem) { + if (this.customRanking == null) { + this.customRanking = new ArrayList<>(); + } + this.customRanking.add(customRankingItem); + return this; + } + + /** + * Specifies the custom ranking criterion. + * + * @return customRanking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specifies the custom ranking criterion.") + public List getCustomRanking() { + return customRanking; + } + + public void setCustomRanking(List customRanking) { + this.customRanking = customRanking; + } + + public IndexSettings relevancyStrictness(Integer relevancyStrictness) { + this.relevancyStrictness = relevancyStrictness; + return this; + } + + /** + * Controls the relevancy threshold below which less relevant results aren’t included in the + * results. + * + * @return relevancyStrictness + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls the relevancy threshold below which less relevant results aren’t included in" + + " the results." + ) + public Integer getRelevancyStrictness() { + return relevancyStrictness; + } + + public void setRelevancyStrictness(Integer relevancyStrictness) { + this.relevancyStrictness = relevancyStrictness; + } + + public IndexSettings attributesToHighlight( + List attributesToHighlight + ) { + this.attributesToHighlight = attributesToHighlight; + return this; + } + + public IndexSettings addAttributesToHighlightItem( + String attributesToHighlightItem + ) { + if (this.attributesToHighlight == null) { + this.attributesToHighlight = new ArrayList<>(); + } + this.attributesToHighlight.add(attributesToHighlightItem); + return this; + } + + /** + * List of attributes to highlight. + * + * @return attributesToHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of attributes to highlight.") + public List getAttributesToHighlight() { + return attributesToHighlight; + } + + public void setAttributesToHighlight(List attributesToHighlight) { + this.attributesToHighlight = attributesToHighlight; + } + + public IndexSettings attributesToSnippet(List attributesToSnippet) { + this.attributesToSnippet = attributesToSnippet; + return this; + } + + public IndexSettings addAttributesToSnippetItem( + String attributesToSnippetItem + ) { + if (this.attributesToSnippet == null) { + this.attributesToSnippet = new ArrayList<>(); + } + this.attributesToSnippet.add(attributesToSnippetItem); + return this; + } + + /** + * List of attributes to snippet, with an optional maximum number of words to snippet. + * + * @return attributesToSnippet + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes to snippet, with an optional maximum number of words to snippet." + ) + public List getAttributesToSnippet() { + return attributesToSnippet; + } + + public void setAttributesToSnippet(List attributesToSnippet) { + this.attributesToSnippet = attributesToSnippet; + } + + public IndexSettings highlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + return this; + } + + /** + * The HTML string to insert before the highlighted parts in all highlight and snippet results. + * + * @return highlightPreTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert before the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPreTag() { + return highlightPreTag; + } + + public void setHighlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + } + + public IndexSettings highlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + return this; + } + + /** + * The HTML string to insert after the highlighted parts in all highlight and snippet results. + * + * @return highlightPostTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert after the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPostTag() { + return highlightPostTag; + } + + public void setHighlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + } + + public IndexSettings snippetEllipsisText(String snippetEllipsisText) { + this.snippetEllipsisText = snippetEllipsisText; + return this; + } + + /** + * String used as an ellipsis indicator when a snippet is truncated. + * + * @return snippetEllipsisText + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "String used as an ellipsis indicator when a snippet is truncated." + ) + public String getSnippetEllipsisText() { + return snippetEllipsisText; + } + + public void setSnippetEllipsisText(String snippetEllipsisText) { + this.snippetEllipsisText = snippetEllipsisText; + } + + public IndexSettings restrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + return this; + } + + /** + * Restrict highlighting and snippeting to items that matched the query. + * + * @return restrictHighlightAndSnippetArrays + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restrict highlighting and snippeting to items that matched the query." + ) + public Boolean getRestrictHighlightAndSnippetArrays() { + return restrictHighlightAndSnippetArrays; + } + + public void setRestrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + } + + public IndexSettings hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public IndexSettings minWordSizefor1Typo(Integer minWordSizefor1Typo) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 1 + * typo. + * + * @return minWordSizefor1Typo + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 1 typo." + ) + public Integer getMinWordSizefor1Typo() { + return minWordSizefor1Typo; + } + + public void setMinWordSizefor1Typo(Integer minWordSizefor1Typo) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + } + + public IndexSettings minWordSizefor2Typos(Integer minWordSizefor2Typos) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 2 + * typos. + * + * @return minWordSizefor2Typos + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 2 typos." + ) + public Integer getMinWordSizefor2Typos() { + return minWordSizefor2Typos; + } + + public void setMinWordSizefor2Typos(Integer minWordSizefor2Typos) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + } + + public IndexSettings typoTolerance(TypoToleranceEnum typoTolerance) { + this.typoTolerance = typoTolerance; + return this; + } + + /** + * Controls whether typo tolerance is enabled and how it is applied. + * + * @return typoTolerance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls whether typo tolerance is enabled and how it is applied." + ) + public TypoToleranceEnum getTypoTolerance() { + return typoTolerance; + } + + public void setTypoTolerance(TypoToleranceEnum typoTolerance) { + this.typoTolerance = typoTolerance; + } + + public IndexSettings allowTyposOnNumericTokens( + Boolean allowTyposOnNumericTokens + ) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + return this; + } + + /** + * Whether to allow typos on numbers (“numeric tokens”) in the query string. + * + * @return allowTyposOnNumericTokens + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to allow typos on numbers (“numeric tokens”) in the query string." + ) + public Boolean getAllowTyposOnNumericTokens() { + return allowTyposOnNumericTokens; + } + + public void setAllowTyposOnNumericTokens(Boolean allowTyposOnNumericTokens) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + } + + public IndexSettings disableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + return this; + } + + public IndexSettings addDisableTypoToleranceOnAttributesItem( + String disableTypoToleranceOnAttributesItem + ) { + if (this.disableTypoToleranceOnAttributes == null) { + this.disableTypoToleranceOnAttributes = new ArrayList<>(); + } + this.disableTypoToleranceOnAttributes.add( + disableTypoToleranceOnAttributesItem + ); + return this; + } + + /** + * List of attributes on which you want to disable typo tolerance. + * + * @return disableTypoToleranceOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable typo tolerance." + ) + public List getDisableTypoToleranceOnAttributes() { + return disableTypoToleranceOnAttributes; + } + + public void setDisableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + } + + public IndexSettings separatorsToIndex(String separatorsToIndex) { + this.separatorsToIndex = separatorsToIndex; + return this; + } + + /** + * Control which separators are indexed. + * + * @return separatorsToIndex + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Control which separators are indexed.") + public String getSeparatorsToIndex() { + return separatorsToIndex; + } + + public void setSeparatorsToIndex(String separatorsToIndex) { + this.separatorsToIndex = separatorsToIndex; + } + + public IndexSettings ignorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + return this; + } + + /** + * Treats singular, plurals, and other forms of declensions as matching terms. + * + * @return ignorePlurals + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Treats singular, plurals, and other forms of declensions as matching terms." + ) + public String getIgnorePlurals() { + return ignorePlurals; + } + + public void setIgnorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + } + + public IndexSettings removeStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + return this; + } + + /** + * Removes stop (common) words from the query before executing it. + * + * @return removeStopWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Removes stop (common) words from the query before executing it." + ) + public String getRemoveStopWords() { + return removeStopWords; + } + + public void setRemoveStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + } + + public IndexSettings keepDiacriticsOnCharacters( + String keepDiacriticsOnCharacters + ) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + return this; + } + + /** + * List of characters that the engine shouldn’t automatically normalize. + * + * @return keepDiacriticsOnCharacters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of characters that the engine shouldn’t automatically normalize." + ) + public String getKeepDiacriticsOnCharacters() { + return keepDiacriticsOnCharacters; + } + + public void setKeepDiacriticsOnCharacters(String keepDiacriticsOnCharacters) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + } + + public IndexSettings queryLanguages(List queryLanguages) { + this.queryLanguages = queryLanguages; + return this; + } + + public IndexSettings addQueryLanguagesItem(String queryLanguagesItem) { + if (this.queryLanguages == null) { + this.queryLanguages = new ArrayList<>(); + } + this.queryLanguages.add(queryLanguagesItem); + return this; + } + + /** + * Sets the languages to be used by language-specific settings and functionalities such as + * ignorePlurals, removeStopWords, and CJK word-detection. + * + * @return queryLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Sets the languages to be used by language-specific settings and functionalities such as" + + " ignorePlurals, removeStopWords, and CJK word-detection." + ) + public List getQueryLanguages() { + return queryLanguages; + } + + public void setQueryLanguages(List queryLanguages) { + this.queryLanguages = queryLanguages; + } + + public IndexSettings decompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + return this; + } + + /** + * Splits compound words into their composing atoms in the query. + * + * @return decompoundQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Splits compound words into their composing atoms in the query." + ) + public Boolean getDecompoundQuery() { + return decompoundQuery; + } + + public void setDecompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + } + + public IndexSettings enableRules(Boolean enableRules) { + this.enableRules = enableRules; + return this; + } + + /** + * Whether Rules should be globally enabled. + * + * @return enableRules + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether Rules should be globally enabled.") + public Boolean getEnableRules() { + return enableRules; + } + + public void setEnableRules(Boolean enableRules) { + this.enableRules = enableRules; + } + + public IndexSettings enablePersonalization(Boolean enablePersonalization) { + this.enablePersonalization = enablePersonalization; + return this; + } + + /** + * Enable the Personalization feature. + * + * @return enablePersonalization + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enable the Personalization feature.") + public Boolean getEnablePersonalization() { + return enablePersonalization; + } + + public void setEnablePersonalization(Boolean enablePersonalization) { + this.enablePersonalization = enablePersonalization; + } + + public IndexSettings queryType(QueryTypeEnum queryType) { + this.queryType = queryType; + return this; + } + + /** + * Controls if and how query words are interpreted as prefixes. + * + * @return queryType + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls if and how query words are interpreted as prefixes." + ) + public QueryTypeEnum getQueryType() { + return queryType; + } + + public void setQueryType(QueryTypeEnum queryType) { + this.queryType = queryType; + } + + public IndexSettings removeWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + return this; + } + + /** + * Selects a strategy to remove words from the query when it doesn’t match any hits. + * + * @return removeWordsIfNoResults + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Selects a strategy to remove words from the query when it doesn’t match any hits." + ) + public RemoveWordsIfNoResultsEnum getRemoveWordsIfNoResults() { + return removeWordsIfNoResults; + } + + public void setRemoveWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + } + + public IndexSettings advancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + return this; + } + + /** + * Enables the advanced query syntax. + * + * @return advancedSyntax + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables the advanced query syntax.") + public Boolean getAdvancedSyntax() { + return advancedSyntax; + } + + public void setAdvancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + } + + public IndexSettings optionalWords(List optionalWords) { + this.optionalWords = optionalWords; + return this; + } + + public IndexSettings addOptionalWordsItem(String optionalWordsItem) { + if (this.optionalWords == null) { + this.optionalWords = new ArrayList<>(); + } + this.optionalWords.add(optionalWordsItem); + return this; + } + + /** + * A list of words that should be considered as optional when found in the query. + * + * @return optionalWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A list of words that should be considered as optional when found in the query." + ) + public List getOptionalWords() { + return optionalWords; + } + + public void setOptionalWords(List optionalWords) { + this.optionalWords = optionalWords; + } + + public IndexSettings disableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + return this; + } + + public IndexSettings addDisableExactOnAttributesItem( + String disableExactOnAttributesItem + ) { + if (this.disableExactOnAttributes == null) { + this.disableExactOnAttributes = new ArrayList<>(); + } + this.disableExactOnAttributes.add(disableExactOnAttributesItem); + return this; + } + + /** + * List of attributes on which you want to disable the exact ranking criterion. + * + * @return disableExactOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable the exact ranking criterion." + ) + public List getDisableExactOnAttributes() { + return disableExactOnAttributes; + } + + public void setDisableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + } + + public IndexSettings exactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + return this; + } + + /** + * Controls how the exact ranking criterion is computed when the query contains only one word. + * + * @return exactOnSingleWordQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls how the exact ranking criterion is computed when the query contains only one" + + " word." + ) + public ExactOnSingleWordQueryEnum getExactOnSingleWordQuery() { + return exactOnSingleWordQuery; + } + + public void setExactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + } + + public IndexSettings alternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + return this; + } + + public IndexSettings addAlternativesAsExactItem( + AlternativesAsExactEnum alternativesAsExactItem + ) { + if (this.alternativesAsExact == null) { + this.alternativesAsExact = new ArrayList<>(); + } + this.alternativesAsExact.add(alternativesAsExactItem); + return this; + } + + /** + * List of alternatives that should be considered an exact match by the exact ranking criterion. + * + * @return alternativesAsExact + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of alternatives that should be considered an exact match by the exact ranking" + + " criterion." + ) + public List getAlternativesAsExact() { + return alternativesAsExact; + } + + public void setAlternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + } + + public IndexSettings advancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + return this; + } + + public IndexSettings addAdvancedSyntaxFeaturesItem( + AdvancedSyntaxFeaturesEnum advancedSyntaxFeaturesItem + ) { + if (this.advancedSyntaxFeatures == null) { + this.advancedSyntaxFeatures = new ArrayList<>(); + } + this.advancedSyntaxFeatures.add(advancedSyntaxFeaturesItem); + return this; + } + + /** + * Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is + * enabled. + * + * @return advancedSyntaxFeatures + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is" + + " enabled." + ) + public List getAdvancedSyntaxFeatures() { + return advancedSyntaxFeatures; + } + + public void setAdvancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + } + + public IndexSettings distinct(Integer distinct) { + this.distinct = distinct; + return this; + } + + /** + * Enables de-duplication or grouping of results. minimum: 0 maximum: 4 + * + * @return distinct + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables de-duplication or grouping of results.") + public Integer getDistinct() { + return distinct; + } + + public void setDistinct(Integer distinct) { + this.distinct = distinct; + } + + public IndexSettings synonyms(Boolean synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Whether to take into account an index’s synonyms for a particular search. + * + * @return synonyms + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to take into account an index’s synonyms for a particular search." + ) + public Boolean getSynonyms() { + return synonyms; + } + + public void setSynonyms(Boolean synonyms) { + this.synonyms = synonyms; + } + + public IndexSettings replaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + return this; + } + + /** + * Whether to highlight and snippet the original word that matches the synonym or the synonym + * itself. + * + * @return replaceSynonymsInHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to highlight and snippet the original word that matches the synonym or the" + + " synonym itself." + ) + public Boolean getReplaceSynonymsInHighlight() { + return replaceSynonymsInHighlight; + } + + public void setReplaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + } + + public IndexSettings minProximity(Integer minProximity) { + this.minProximity = minProximity; + return this; + } + + /** + * Precision of the proximity ranking criterion. minimum: 1 maximum: 7 + * + * @return minProximity + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Precision of the proximity ranking criterion.") + public Integer getMinProximity() { + return minProximity; + } + + public void setMinProximity(Integer minProximity) { + this.minProximity = minProximity; + } + + public IndexSettings responseFields(List responseFields) { + this.responseFields = responseFields; + return this; + } + + public IndexSettings addResponseFieldsItem(String responseFieldsItem) { + if (this.responseFields == null) { + this.responseFields = new ArrayList<>(); + } + this.responseFields.add(responseFieldsItem); + return this; + } + + /** + * Choose which fields to return in the API response. This parameters applies to search and browse + * queries. + * + * @return responseFields + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Choose which fields to return in the API response. This parameters applies to search and" + + " browse queries." + ) + public List getResponseFields() { + return responseFields; + } + + public void setResponseFields(List responseFields) { + this.responseFields = responseFields; + } + + public IndexSettings maxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + return this; + } + + /** + * Maximum number of facet hits to return during a search for facet values. + * + * @return maxFacetHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet hits to return during a search for facet values." + ) + public Integer getMaxFacetHits() { + return maxFacetHits; + } + + public void setMaxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + } + + public IndexSettings attributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + return this; + } + + /** + * When attribute is ranked above proximity in your ranking formula, proximity is used to select + * which searchable attribute is matched in the attribute ranking stage. + * + * @return attributeCriteriaComputedByMinProximity + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "When attribute is ranked above proximity in your ranking formula, proximity is used to" + + " select which searchable attribute is matched in the attribute ranking stage." + ) + public Boolean getAttributeCriteriaComputedByMinProximity() { + return attributeCriteriaComputedByMinProximity; + } + + public void setAttributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + } + + public IndexSettings renderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + return this; + } + + /** + * Content defining how the search interface should be rendered. Can be set via the settings for a + * default value and can be overridden via rules. + * + * @return renderingContent + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Content defining how the search interface should be rendered. Can be set via the" + + " settings for a default value and can be overridden via rules." + ) + public Object getRenderingContent() { + return renderingContent; + } + + public void setRenderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexSettings indexSettings = (IndexSettings) o; + return ( + Objects.equals(this.replicas, indexSettings.replicas) && + Objects.equals( + this.paginationLimitedTo, + indexSettings.paginationLimitedTo + ) && + Objects.equals( + this.disableTypoToleranceOnWords, + indexSettings.disableTypoToleranceOnWords + ) && + Objects.equals( + this.attributesToTransliterate, + indexSettings.attributesToTransliterate + ) && + Objects.equals( + this.camelCaseAttributes, + indexSettings.camelCaseAttributes + ) && + Objects.equals( + this.decompoundedAttributes, + indexSettings.decompoundedAttributes + ) && + Objects.equals(this.indexLanguages, indexSettings.indexLanguages) && + Objects.equals(this.filterPromotes, indexSettings.filterPromotes) && + Objects.equals( + this.disablePrefixOnAttributes, + indexSettings.disablePrefixOnAttributes + ) && + Objects.equals( + this.allowCompressionOfIntegerArray, + indexSettings.allowCompressionOfIntegerArray + ) && + Objects.equals( + this.numericAttributesForFiltering, + indexSettings.numericAttributesForFiltering + ) && + Objects.equals(this.userData, indexSettings.userData) && + Objects.equals( + this.searchableAttributes, + indexSettings.searchableAttributes + ) && + Objects.equals( + this.attributesForFaceting, + indexSettings.attributesForFaceting + ) && + Objects.equals( + this.unretrievableAttributes, + indexSettings.unretrievableAttributes + ) && + Objects.equals( + this.attributesToRetrieve, + indexSettings.attributesToRetrieve + ) && + Objects.equals( + this.restrictSearchableAttributes, + indexSettings.restrictSearchableAttributes + ) && + Objects.equals(this.ranking, indexSettings.ranking) && + Objects.equals(this.customRanking, indexSettings.customRanking) && + Objects.equals( + this.relevancyStrictness, + indexSettings.relevancyStrictness + ) && + Objects.equals( + this.attributesToHighlight, + indexSettings.attributesToHighlight + ) && + Objects.equals( + this.attributesToSnippet, + indexSettings.attributesToSnippet + ) && + Objects.equals(this.highlightPreTag, indexSettings.highlightPreTag) && + Objects.equals(this.highlightPostTag, indexSettings.highlightPostTag) && + Objects.equals( + this.snippetEllipsisText, + indexSettings.snippetEllipsisText + ) && + Objects.equals( + this.restrictHighlightAndSnippetArrays, + indexSettings.restrictHighlightAndSnippetArrays + ) && + Objects.equals(this.hitsPerPage, indexSettings.hitsPerPage) && + Objects.equals( + this.minWordSizefor1Typo, + indexSettings.minWordSizefor1Typo + ) && + Objects.equals( + this.minWordSizefor2Typos, + indexSettings.minWordSizefor2Typos + ) && + Objects.equals(this.typoTolerance, indexSettings.typoTolerance) && + Objects.equals( + this.allowTyposOnNumericTokens, + indexSettings.allowTyposOnNumericTokens + ) && + Objects.equals( + this.disableTypoToleranceOnAttributes, + indexSettings.disableTypoToleranceOnAttributes + ) && + Objects.equals(this.separatorsToIndex, indexSettings.separatorsToIndex) && + Objects.equals(this.ignorePlurals, indexSettings.ignorePlurals) && + Objects.equals(this.removeStopWords, indexSettings.removeStopWords) && + Objects.equals( + this.keepDiacriticsOnCharacters, + indexSettings.keepDiacriticsOnCharacters + ) && + Objects.equals(this.queryLanguages, indexSettings.queryLanguages) && + Objects.equals(this.decompoundQuery, indexSettings.decompoundQuery) && + Objects.equals(this.enableRules, indexSettings.enableRules) && + Objects.equals( + this.enablePersonalization, + indexSettings.enablePersonalization + ) && + Objects.equals(this.queryType, indexSettings.queryType) && + Objects.equals( + this.removeWordsIfNoResults, + indexSettings.removeWordsIfNoResults + ) && + Objects.equals(this.advancedSyntax, indexSettings.advancedSyntax) && + Objects.equals(this.optionalWords, indexSettings.optionalWords) && + Objects.equals( + this.disableExactOnAttributes, + indexSettings.disableExactOnAttributes + ) && + Objects.equals( + this.exactOnSingleWordQuery, + indexSettings.exactOnSingleWordQuery + ) && + Objects.equals( + this.alternativesAsExact, + indexSettings.alternativesAsExact + ) && + Objects.equals( + this.advancedSyntaxFeatures, + indexSettings.advancedSyntaxFeatures + ) && + Objects.equals(this.distinct, indexSettings.distinct) && + Objects.equals(this.synonyms, indexSettings.synonyms) && + Objects.equals( + this.replaceSynonymsInHighlight, + indexSettings.replaceSynonymsInHighlight + ) && + Objects.equals(this.minProximity, indexSettings.minProximity) && + Objects.equals(this.responseFields, indexSettings.responseFields) && + Objects.equals(this.maxFacetHits, indexSettings.maxFacetHits) && + Objects.equals( + this.attributeCriteriaComputedByMinProximity, + indexSettings.attributeCriteriaComputedByMinProximity + ) && + Objects.equals(this.renderingContent, indexSettings.renderingContent) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + replicas, + paginationLimitedTo, + disableTypoToleranceOnWords, + attributesToTransliterate, + camelCaseAttributes, + decompoundedAttributes, + indexLanguages, + filterPromotes, + disablePrefixOnAttributes, + allowCompressionOfIntegerArray, + numericAttributesForFiltering, + userData, + searchableAttributes, + attributesForFaceting, + unretrievableAttributes, + attributesToRetrieve, + restrictSearchableAttributes, + ranking, + customRanking, + relevancyStrictness, + attributesToHighlight, + attributesToSnippet, + highlightPreTag, + highlightPostTag, + snippetEllipsisText, + restrictHighlightAndSnippetArrays, + hitsPerPage, + minWordSizefor1Typo, + minWordSizefor2Typos, + typoTolerance, + allowTyposOnNumericTokens, + disableTypoToleranceOnAttributes, + separatorsToIndex, + ignorePlurals, + removeStopWords, + keepDiacriticsOnCharacters, + queryLanguages, + decompoundQuery, + enableRules, + enablePersonalization, + queryType, + removeWordsIfNoResults, + advancedSyntax, + optionalWords, + disableExactOnAttributes, + exactOnSingleWordQuery, + alternativesAsExact, + advancedSyntaxFeatures, + distinct, + synonyms, + replaceSynonymsInHighlight, + minProximity, + responseFields, + maxFacetHits, + attributeCriteriaComputedByMinProximity, + renderingContent + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexSettings {\n"); + sb.append(" replicas: ").append(toIndentedString(replicas)).append("\n"); + sb + .append(" paginationLimitedTo: ") + .append(toIndentedString(paginationLimitedTo)) + .append("\n"); + sb + .append(" disableTypoToleranceOnWords: ") + .append(toIndentedString(disableTypoToleranceOnWords)) + .append("\n"); + sb + .append(" attributesToTransliterate: ") + .append(toIndentedString(attributesToTransliterate)) + .append("\n"); + sb + .append(" camelCaseAttributes: ") + .append(toIndentedString(camelCaseAttributes)) + .append("\n"); + sb + .append(" decompoundedAttributes: ") + .append(toIndentedString(decompoundedAttributes)) + .append("\n"); + sb + .append(" indexLanguages: ") + .append(toIndentedString(indexLanguages)) + .append("\n"); + sb + .append(" filterPromotes: ") + .append(toIndentedString(filterPromotes)) + .append("\n"); + sb + .append(" disablePrefixOnAttributes: ") + .append(toIndentedString(disablePrefixOnAttributes)) + .append("\n"); + sb + .append(" allowCompressionOfIntegerArray: ") + .append(toIndentedString(allowCompressionOfIntegerArray)) + .append("\n"); + sb + .append(" numericAttributesForFiltering: ") + .append(toIndentedString(numericAttributesForFiltering)) + .append("\n"); + sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); + sb + .append(" searchableAttributes: ") + .append(toIndentedString(searchableAttributes)) + .append("\n"); + sb + .append(" attributesForFaceting: ") + .append(toIndentedString(attributesForFaceting)) + .append("\n"); + sb + .append(" unretrievableAttributes: ") + .append(toIndentedString(unretrievableAttributes)) + .append("\n"); + sb + .append(" attributesToRetrieve: ") + .append(toIndentedString(attributesToRetrieve)) + .append("\n"); + sb + .append(" restrictSearchableAttributes: ") + .append(toIndentedString(restrictSearchableAttributes)) + .append("\n"); + sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n"); + sb + .append(" customRanking: ") + .append(toIndentedString(customRanking)) + .append("\n"); + sb + .append(" relevancyStrictness: ") + .append(toIndentedString(relevancyStrictness)) + .append("\n"); + sb + .append(" attributesToHighlight: ") + .append(toIndentedString(attributesToHighlight)) + .append("\n"); + sb + .append(" attributesToSnippet: ") + .append(toIndentedString(attributesToSnippet)) + .append("\n"); + sb + .append(" highlightPreTag: ") + .append(toIndentedString(highlightPreTag)) + .append("\n"); + sb + .append(" highlightPostTag: ") + .append(toIndentedString(highlightPostTag)) + .append("\n"); + sb + .append(" snippetEllipsisText: ") + .append(toIndentedString(snippetEllipsisText)) + .append("\n"); + sb + .append(" restrictHighlightAndSnippetArrays: ") + .append(toIndentedString(restrictHighlightAndSnippetArrays)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb + .append(" minWordSizefor1Typo: ") + .append(toIndentedString(minWordSizefor1Typo)) + .append("\n"); + sb + .append(" minWordSizefor2Typos: ") + .append(toIndentedString(minWordSizefor2Typos)) + .append("\n"); + sb + .append(" typoTolerance: ") + .append(toIndentedString(typoTolerance)) + .append("\n"); + sb + .append(" allowTyposOnNumericTokens: ") + .append(toIndentedString(allowTyposOnNumericTokens)) + .append("\n"); + sb + .append(" disableTypoToleranceOnAttributes: ") + .append(toIndentedString(disableTypoToleranceOnAttributes)) + .append("\n"); + sb + .append(" separatorsToIndex: ") + .append(toIndentedString(separatorsToIndex)) + .append("\n"); + sb + .append(" ignorePlurals: ") + .append(toIndentedString(ignorePlurals)) + .append("\n"); + sb + .append(" removeStopWords: ") + .append(toIndentedString(removeStopWords)) + .append("\n"); + sb + .append(" keepDiacriticsOnCharacters: ") + .append(toIndentedString(keepDiacriticsOnCharacters)) + .append("\n"); + sb + .append(" queryLanguages: ") + .append(toIndentedString(queryLanguages)) + .append("\n"); + sb + .append(" decompoundQuery: ") + .append(toIndentedString(decompoundQuery)) + .append("\n"); + sb + .append(" enableRules: ") + .append(toIndentedString(enableRules)) + .append("\n"); + sb + .append(" enablePersonalization: ") + .append(toIndentedString(enablePersonalization)) + .append("\n"); + sb + .append(" queryType: ") + .append(toIndentedString(queryType)) + .append("\n"); + sb + .append(" removeWordsIfNoResults: ") + .append(toIndentedString(removeWordsIfNoResults)) + .append("\n"); + sb + .append(" advancedSyntax: ") + .append(toIndentedString(advancedSyntax)) + .append("\n"); + sb + .append(" optionalWords: ") + .append(toIndentedString(optionalWords)) + .append("\n"); + sb + .append(" disableExactOnAttributes: ") + .append(toIndentedString(disableExactOnAttributes)) + .append("\n"); + sb + .append(" exactOnSingleWordQuery: ") + .append(toIndentedString(exactOnSingleWordQuery)) + .append("\n"); + sb + .append(" alternativesAsExact: ") + .append(toIndentedString(alternativesAsExact)) + .append("\n"); + sb + .append(" advancedSyntaxFeatures: ") + .append(toIndentedString(advancedSyntaxFeatures)) + .append("\n"); + sb.append(" distinct: ").append(toIndentedString(distinct)).append("\n"); + sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n"); + sb + .append(" replaceSynonymsInHighlight: ") + .append(toIndentedString(replaceSynonymsInHighlight)) + .append("\n"); + sb + .append(" minProximity: ") + .append(toIndentedString(minProximity)) + .append("\n"); + sb + .append(" responseFields: ") + .append(toIndentedString(responseFields)) + .append("\n"); + sb + .append(" maxFacetHits: ") + .append(toIndentedString(maxFacetHits)) + .append("\n"); + sb + .append(" attributeCriteriaComputedByMinProximity: ") + .append(toIndentedString(attributeCriteriaComputedByMinProximity)) + .append("\n"); + sb + .append(" renderingContent: ") + .append(toIndentedString(renderingContent)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java new file mode 100644 index 00000000000..88e9177b84f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/IndexSettingsAsSearchParams.java @@ -0,0 +1,2202 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** IndexSettingsAsSearchParams */ +public class IndexSettingsAsSearchParams { + + public static final String SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES = + "searchableAttributes"; + + @SerializedName(SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES) + private List searchableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING = + "attributesForFaceting"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING) + private List attributesForFaceting = null; + + public static final String SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES = + "unretrievableAttributes"; + + @SerializedName(SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES) + private List unretrievableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE = + "attributesToRetrieve"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE) + private List attributesToRetrieve = null; + + public static final String SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES = + "restrictSearchableAttributes"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES) + private List restrictSearchableAttributes = null; + + public static final String SERIALIZED_NAME_RANKING = "ranking"; + + @SerializedName(SERIALIZED_NAME_RANKING) + private List ranking = null; + + public static final String SERIALIZED_NAME_CUSTOM_RANKING = "customRanking"; + + @SerializedName(SERIALIZED_NAME_CUSTOM_RANKING) + private List customRanking = null; + + public static final String SERIALIZED_NAME_RELEVANCY_STRICTNESS = + "relevancyStrictness"; + + @SerializedName(SERIALIZED_NAME_RELEVANCY_STRICTNESS) + private Integer relevancyStrictness = 100; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT = + "attributesToHighlight"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT) + private List attributesToHighlight = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET = + "attributesToSnippet"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET) + private List attributesToSnippet = null; + + public static final String SERIALIZED_NAME_HIGHLIGHT_PRE_TAG = + "highlightPreTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_PRE_TAG) + private String highlightPreTag = ""; + + public static final String SERIALIZED_NAME_HIGHLIGHT_POST_TAG = + "highlightPostTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_POST_TAG) + private String highlightPostTag = ""; + + public static final String SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT = + "snippetEllipsisText"; + + @SerializedName(SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT) + private String snippetEllipsisText = "…"; + + public static final String SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS = + "restrictHighlightAndSnippetArrays"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS) + private Boolean restrictHighlightAndSnippetArrays = false; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO = + "minWordSizefor1Typo"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO) + private Integer minWordSizefor1Typo = 4; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS = + "minWordSizefor2Typos"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS) + private Integer minWordSizefor2Typos = 8; + + /** Controls whether typo tolerance is enabled and how it is applied. */ + @JsonAdapter(TypoToleranceEnum.Adapter.class) + public enum TypoToleranceEnum { + TRUE("true"), + + FALSE("false"), + + MIN("min"), + + STRICT("strict"); + + private String value; + + TypoToleranceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypoToleranceEnum fromValue(String value) { + for (TypoToleranceEnum b : TypoToleranceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final TypoToleranceEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypoToleranceEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return TypoToleranceEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPO_TOLERANCE = "typoTolerance"; + + @SerializedName(SERIALIZED_NAME_TYPO_TOLERANCE) + private TypoToleranceEnum typoTolerance = TypoToleranceEnum.TRUE; + + public static final String SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS = + "allowTyposOnNumericTokens"; + + @SerializedName(SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS) + private Boolean allowTyposOnNumericTokens = true; + + public static final String SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES = + "disableTypoToleranceOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES) + private List disableTypoToleranceOnAttributes = null; + + public static final String SERIALIZED_NAME_SEPARATORS_TO_INDEX = + "separatorsToIndex"; + + @SerializedName(SERIALIZED_NAME_SEPARATORS_TO_INDEX) + private String separatorsToIndex = ""; + + public static final String SERIALIZED_NAME_IGNORE_PLURALS = "ignorePlurals"; + + @SerializedName(SERIALIZED_NAME_IGNORE_PLURALS) + private String ignorePlurals = "false"; + + public static final String SERIALIZED_NAME_REMOVE_STOP_WORDS = + "removeStopWords"; + + @SerializedName(SERIALIZED_NAME_REMOVE_STOP_WORDS) + private String removeStopWords = "false"; + + public static final String SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS = + "keepDiacriticsOnCharacters"; + + @SerializedName(SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS) + private String keepDiacriticsOnCharacters = ""; + + public static final String SERIALIZED_NAME_QUERY_LANGUAGES = "queryLanguages"; + + @SerializedName(SERIALIZED_NAME_QUERY_LANGUAGES) + private List queryLanguages = null; + + public static final String SERIALIZED_NAME_DECOMPOUND_QUERY = + "decompoundQuery"; + + @SerializedName(SERIALIZED_NAME_DECOMPOUND_QUERY) + private Boolean decompoundQuery = true; + + public static final String SERIALIZED_NAME_ENABLE_RULES = "enableRules"; + + @SerializedName(SERIALIZED_NAME_ENABLE_RULES) + private Boolean enableRules = true; + + public static final String SERIALIZED_NAME_ENABLE_PERSONALIZATION = + "enablePersonalization"; + + @SerializedName(SERIALIZED_NAME_ENABLE_PERSONALIZATION) + private Boolean enablePersonalization = false; + + /** Controls if and how query words are interpreted as prefixes. */ + @JsonAdapter(QueryTypeEnum.Adapter.class) + public enum QueryTypeEnum { + PREFIXLAST("prefixLast"), + + PREFIXALL("prefixAll"), + + PREFIXNONE("prefixNone"); + + private String value; + + QueryTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static QueryTypeEnum fromValue(String value) { + for (QueryTypeEnum b : QueryTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final QueryTypeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public QueryTypeEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return QueryTypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_QUERY_TYPE = "queryType"; + + @SerializedName(SERIALIZED_NAME_QUERY_TYPE) + private QueryTypeEnum queryType = QueryTypeEnum.PREFIXLAST; + + /** Selects a strategy to remove words from the query when it doesn’t match any hits. */ + @JsonAdapter(RemoveWordsIfNoResultsEnum.Adapter.class) + public enum RemoveWordsIfNoResultsEnum { + NONE("none"), + + LASTWORDS("lastWords"), + + FIRSTWORDS("firstWords"), + + ALLOPTIONAL("allOptional"); + + private String value; + + RemoveWordsIfNoResultsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RemoveWordsIfNoResultsEnum fromValue(String value) { + for (RemoveWordsIfNoResultsEnum b : RemoveWordsIfNoResultsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final RemoveWordsIfNoResultsEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RemoveWordsIfNoResultsEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return RemoveWordsIfNoResultsEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS = + "removeWordsIfNoResults"; + + @SerializedName(SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS) + private RemoveWordsIfNoResultsEnum removeWordsIfNoResults = + RemoveWordsIfNoResultsEnum.NONE; + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX = "advancedSyntax"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX) + private Boolean advancedSyntax = false; + + public static final String SERIALIZED_NAME_OPTIONAL_WORDS = "optionalWords"; + + @SerializedName(SERIALIZED_NAME_OPTIONAL_WORDS) + private List optionalWords = null; + + public static final String SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES = + "disableExactOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES) + private List disableExactOnAttributes = null; + + /** Controls how the exact ranking criterion is computed when the query contains only one word. */ + @JsonAdapter(ExactOnSingleWordQueryEnum.Adapter.class) + public enum ExactOnSingleWordQueryEnum { + ATTRIBUTE("attribute"), + + NONE("none"), + + WORD("word"); + + private String value; + + ExactOnSingleWordQueryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ExactOnSingleWordQueryEnum fromValue(String value) { + for (ExactOnSingleWordQueryEnum b : ExactOnSingleWordQueryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final ExactOnSingleWordQueryEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ExactOnSingleWordQueryEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return ExactOnSingleWordQueryEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY = + "exactOnSingleWordQuery"; + + @SerializedName(SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY) + private ExactOnSingleWordQueryEnum exactOnSingleWordQuery = + ExactOnSingleWordQueryEnum.ATTRIBUTE; + + /** Gets or Sets alternativesAsExact */ + @JsonAdapter(AlternativesAsExactEnum.Adapter.class) + public enum AlternativesAsExactEnum { + IGNOREPLURALS("ignorePlurals"), + + SINGLEWORDSYNONYM("singleWordSynonym"), + + MULTIWORDSSYNONYM("multiWordsSynonym"); + + private String value; + + AlternativesAsExactEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AlternativesAsExactEnum fromValue(String value) { + for (AlternativesAsExactEnum b : AlternativesAsExactEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AlternativesAsExactEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AlternativesAsExactEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AlternativesAsExactEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ALTERNATIVES_AS_EXACT = + "alternativesAsExact"; + + @SerializedName(SERIALIZED_NAME_ALTERNATIVES_AS_EXACT) + private List alternativesAsExact = null; + + /** Gets or Sets advancedSyntaxFeatures */ + @JsonAdapter(AdvancedSyntaxFeaturesEnum.Adapter.class) + public enum AdvancedSyntaxFeaturesEnum { + EXACTPHRASE("exactPhrase"), + + EXCLUDEWORDS("excludeWords"); + + private String value; + + AdvancedSyntaxFeaturesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AdvancedSyntaxFeaturesEnum fromValue(String value) { + for (AdvancedSyntaxFeaturesEnum b : AdvancedSyntaxFeaturesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AdvancedSyntaxFeaturesEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AdvancedSyntaxFeaturesEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AdvancedSyntaxFeaturesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES = + "advancedSyntaxFeatures"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES) + private List advancedSyntaxFeatures = null; + + public static final String SERIALIZED_NAME_DISTINCT = "distinct"; + + @SerializedName(SERIALIZED_NAME_DISTINCT) + private Integer distinct = 0; + + public static final String SERIALIZED_NAME_SYNONYMS = "synonyms"; + + @SerializedName(SERIALIZED_NAME_SYNONYMS) + private Boolean synonyms = true; + + public static final String SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT = + "replaceSynonymsInHighlight"; + + @SerializedName(SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT) + private Boolean replaceSynonymsInHighlight = false; + + public static final String SERIALIZED_NAME_MIN_PROXIMITY = "minProximity"; + + @SerializedName(SERIALIZED_NAME_MIN_PROXIMITY) + private Integer minProximity = 1; + + public static final String SERIALIZED_NAME_RESPONSE_FIELDS = "responseFields"; + + @SerializedName(SERIALIZED_NAME_RESPONSE_FIELDS) + private List responseFields = null; + + public static final String SERIALIZED_NAME_MAX_FACET_HITS = "maxFacetHits"; + + @SerializedName(SERIALIZED_NAME_MAX_FACET_HITS) + private Integer maxFacetHits = 10; + + public static final String SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY = + "attributeCriteriaComputedByMinProximity"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY) + private Boolean attributeCriteriaComputedByMinProximity = false; + + public static final String SERIALIZED_NAME_RENDERING_CONTENT = + "renderingContent"; + + @SerializedName(SERIALIZED_NAME_RENDERING_CONTENT) + private Object renderingContent = new Object(); + + public IndexSettingsAsSearchParams searchableAttributes( + List searchableAttributes + ) { + this.searchableAttributes = searchableAttributes; + return this; + } + + public IndexSettingsAsSearchParams addSearchableAttributesItem( + String searchableAttributesItem + ) { + if (this.searchableAttributes == null) { + this.searchableAttributes = new ArrayList<>(); + } + this.searchableAttributes.add(searchableAttributesItem); + return this; + } + + /** + * The complete list of attributes used for searching. + * + * @return searchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes used for searching." + ) + public List getSearchableAttributes() { + return searchableAttributes; + } + + public void setSearchableAttributes(List searchableAttributes) { + this.searchableAttributes = searchableAttributes; + } + + public IndexSettingsAsSearchParams attributesForFaceting( + List attributesForFaceting + ) { + this.attributesForFaceting = attributesForFaceting; + return this; + } + + public IndexSettingsAsSearchParams addAttributesForFacetingItem( + String attributesForFacetingItem + ) { + if (this.attributesForFaceting == null) { + this.attributesForFaceting = new ArrayList<>(); + } + this.attributesForFaceting.add(attributesForFacetingItem); + return this; + } + + /** + * The complete list of attributes that will be used for faceting. + * + * @return attributesForFaceting + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes that will be used for faceting." + ) + public List getAttributesForFaceting() { + return attributesForFaceting; + } + + public void setAttributesForFaceting(List attributesForFaceting) { + this.attributesForFaceting = attributesForFaceting; + } + + public IndexSettingsAsSearchParams unretrievableAttributes( + List unretrievableAttributes + ) { + this.unretrievableAttributes = unretrievableAttributes; + return this; + } + + public IndexSettingsAsSearchParams addUnretrievableAttributesItem( + String unretrievableAttributesItem + ) { + if (this.unretrievableAttributes == null) { + this.unretrievableAttributes = new ArrayList<>(); + } + this.unretrievableAttributes.add(unretrievableAttributesItem); + return this; + } + + /** + * List of attributes that can’t be retrieved at query time. + * + * @return unretrievableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes that can’t be retrieved at query time." + ) + public List getUnretrievableAttributes() { + return unretrievableAttributes; + } + + public void setUnretrievableAttributes(List unretrievableAttributes) { + this.unretrievableAttributes = unretrievableAttributes; + } + + public IndexSettingsAsSearchParams attributesToRetrieve( + List attributesToRetrieve + ) { + this.attributesToRetrieve = attributesToRetrieve; + return this; + } + + public IndexSettingsAsSearchParams addAttributesToRetrieveItem( + String attributesToRetrieveItem + ) { + if (this.attributesToRetrieve == null) { + this.attributesToRetrieve = new ArrayList<>(); + } + this.attributesToRetrieve.add(attributesToRetrieveItem); + return this; + } + + /** + * This parameter controls which attributes to retrieve and which not to retrieve. + * + * @return attributesToRetrieve + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "This parameter controls which attributes to retrieve and which not to retrieve." + ) + public List getAttributesToRetrieve() { + return attributesToRetrieve; + } + + public void setAttributesToRetrieve(List attributesToRetrieve) { + this.attributesToRetrieve = attributesToRetrieve; + } + + public IndexSettingsAsSearchParams restrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + return this; + } + + public IndexSettingsAsSearchParams addRestrictSearchableAttributesItem( + String restrictSearchableAttributesItem + ) { + if (this.restrictSearchableAttributes == null) { + this.restrictSearchableAttributes = new ArrayList<>(); + } + this.restrictSearchableAttributes.add(restrictSearchableAttributesItem); + return this; + } + + /** + * Restricts a given query to look in only a subset of your searchable attributes. + * + * @return restrictSearchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restricts a given query to look in only a subset of your searchable attributes." + ) + public List getRestrictSearchableAttributes() { + return restrictSearchableAttributes; + } + + public void setRestrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + } + + public IndexSettingsAsSearchParams ranking(List ranking) { + this.ranking = ranking; + return this; + } + + public IndexSettingsAsSearchParams addRankingItem(String rankingItem) { + if (this.ranking == null) { + this.ranking = new ArrayList<>(); + } + this.ranking.add(rankingItem); + return this; + } + + /** + * Controls how Algolia should sort your results. + * + * @return ranking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Controls how Algolia should sort your results.") + public List getRanking() { + return ranking; + } + + public void setRanking(List ranking) { + this.ranking = ranking; + } + + public IndexSettingsAsSearchParams customRanking(List customRanking) { + this.customRanking = customRanking; + return this; + } + + public IndexSettingsAsSearchParams addCustomRankingItem( + String customRankingItem + ) { + if (this.customRanking == null) { + this.customRanking = new ArrayList<>(); + } + this.customRanking.add(customRankingItem); + return this; + } + + /** + * Specifies the custom ranking criterion. + * + * @return customRanking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specifies the custom ranking criterion.") + public List getCustomRanking() { + return customRanking; + } + + public void setCustomRanking(List customRanking) { + this.customRanking = customRanking; + } + + public IndexSettingsAsSearchParams relevancyStrictness( + Integer relevancyStrictness + ) { + this.relevancyStrictness = relevancyStrictness; + return this; + } + + /** + * Controls the relevancy threshold below which less relevant results aren’t included in the + * results. + * + * @return relevancyStrictness + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls the relevancy threshold below which less relevant results aren’t included in" + + " the results." + ) + public Integer getRelevancyStrictness() { + return relevancyStrictness; + } + + public void setRelevancyStrictness(Integer relevancyStrictness) { + this.relevancyStrictness = relevancyStrictness; + } + + public IndexSettingsAsSearchParams attributesToHighlight( + List attributesToHighlight + ) { + this.attributesToHighlight = attributesToHighlight; + return this; + } + + public IndexSettingsAsSearchParams addAttributesToHighlightItem( + String attributesToHighlightItem + ) { + if (this.attributesToHighlight == null) { + this.attributesToHighlight = new ArrayList<>(); + } + this.attributesToHighlight.add(attributesToHighlightItem); + return this; + } + + /** + * List of attributes to highlight. + * + * @return attributesToHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of attributes to highlight.") + public List getAttributesToHighlight() { + return attributesToHighlight; + } + + public void setAttributesToHighlight(List attributesToHighlight) { + this.attributesToHighlight = attributesToHighlight; + } + + public IndexSettingsAsSearchParams attributesToSnippet( + List attributesToSnippet + ) { + this.attributesToSnippet = attributesToSnippet; + return this; + } + + public IndexSettingsAsSearchParams addAttributesToSnippetItem( + String attributesToSnippetItem + ) { + if (this.attributesToSnippet == null) { + this.attributesToSnippet = new ArrayList<>(); + } + this.attributesToSnippet.add(attributesToSnippetItem); + return this; + } + + /** + * List of attributes to snippet, with an optional maximum number of words to snippet. + * + * @return attributesToSnippet + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes to snippet, with an optional maximum number of words to snippet." + ) + public List getAttributesToSnippet() { + return attributesToSnippet; + } + + public void setAttributesToSnippet(List attributesToSnippet) { + this.attributesToSnippet = attributesToSnippet; + } + + public IndexSettingsAsSearchParams highlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + return this; + } + + /** + * The HTML string to insert before the highlighted parts in all highlight and snippet results. + * + * @return highlightPreTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert before the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPreTag() { + return highlightPreTag; + } + + public void setHighlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + } + + public IndexSettingsAsSearchParams highlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + return this; + } + + /** + * The HTML string to insert after the highlighted parts in all highlight and snippet results. + * + * @return highlightPostTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert after the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPostTag() { + return highlightPostTag; + } + + public void setHighlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + } + + public IndexSettingsAsSearchParams snippetEllipsisText( + String snippetEllipsisText + ) { + this.snippetEllipsisText = snippetEllipsisText; + return this; + } + + /** + * String used as an ellipsis indicator when a snippet is truncated. + * + * @return snippetEllipsisText + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "String used as an ellipsis indicator when a snippet is truncated." + ) + public String getSnippetEllipsisText() { + return snippetEllipsisText; + } + + public void setSnippetEllipsisText(String snippetEllipsisText) { + this.snippetEllipsisText = snippetEllipsisText; + } + + public IndexSettingsAsSearchParams restrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + return this; + } + + /** + * Restrict highlighting and snippeting to items that matched the query. + * + * @return restrictHighlightAndSnippetArrays + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restrict highlighting and snippeting to items that matched the query." + ) + public Boolean getRestrictHighlightAndSnippetArrays() { + return restrictHighlightAndSnippetArrays; + } + + public void setRestrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + } + + public IndexSettingsAsSearchParams hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public IndexSettingsAsSearchParams minWordSizefor1Typo( + Integer minWordSizefor1Typo + ) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 1 + * typo. + * + * @return minWordSizefor1Typo + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 1 typo." + ) + public Integer getMinWordSizefor1Typo() { + return minWordSizefor1Typo; + } + + public void setMinWordSizefor1Typo(Integer minWordSizefor1Typo) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + } + + public IndexSettingsAsSearchParams minWordSizefor2Typos( + Integer minWordSizefor2Typos + ) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 2 + * typos. + * + * @return minWordSizefor2Typos + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 2 typos." + ) + public Integer getMinWordSizefor2Typos() { + return minWordSizefor2Typos; + } + + public void setMinWordSizefor2Typos(Integer minWordSizefor2Typos) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + } + + public IndexSettingsAsSearchParams typoTolerance( + TypoToleranceEnum typoTolerance + ) { + this.typoTolerance = typoTolerance; + return this; + } + + /** + * Controls whether typo tolerance is enabled and how it is applied. + * + * @return typoTolerance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls whether typo tolerance is enabled and how it is applied." + ) + public TypoToleranceEnum getTypoTolerance() { + return typoTolerance; + } + + public void setTypoTolerance(TypoToleranceEnum typoTolerance) { + this.typoTolerance = typoTolerance; + } + + public IndexSettingsAsSearchParams allowTyposOnNumericTokens( + Boolean allowTyposOnNumericTokens + ) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + return this; + } + + /** + * Whether to allow typos on numbers (“numeric tokens”) in the query string. + * + * @return allowTyposOnNumericTokens + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to allow typos on numbers (“numeric tokens”) in the query string." + ) + public Boolean getAllowTyposOnNumericTokens() { + return allowTyposOnNumericTokens; + } + + public void setAllowTyposOnNumericTokens(Boolean allowTyposOnNumericTokens) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + } + + public IndexSettingsAsSearchParams disableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + return this; + } + + public IndexSettingsAsSearchParams addDisableTypoToleranceOnAttributesItem( + String disableTypoToleranceOnAttributesItem + ) { + if (this.disableTypoToleranceOnAttributes == null) { + this.disableTypoToleranceOnAttributes = new ArrayList<>(); + } + this.disableTypoToleranceOnAttributes.add( + disableTypoToleranceOnAttributesItem + ); + return this; + } + + /** + * List of attributes on which you want to disable typo tolerance. + * + * @return disableTypoToleranceOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable typo tolerance." + ) + public List getDisableTypoToleranceOnAttributes() { + return disableTypoToleranceOnAttributes; + } + + public void setDisableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + } + + public IndexSettingsAsSearchParams separatorsToIndex( + String separatorsToIndex + ) { + this.separatorsToIndex = separatorsToIndex; + return this; + } + + /** + * Control which separators are indexed. + * + * @return separatorsToIndex + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Control which separators are indexed.") + public String getSeparatorsToIndex() { + return separatorsToIndex; + } + + public void setSeparatorsToIndex(String separatorsToIndex) { + this.separatorsToIndex = separatorsToIndex; + } + + public IndexSettingsAsSearchParams ignorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + return this; + } + + /** + * Treats singular, plurals, and other forms of declensions as matching terms. + * + * @return ignorePlurals + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Treats singular, plurals, and other forms of declensions as matching terms." + ) + public String getIgnorePlurals() { + return ignorePlurals; + } + + public void setIgnorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + } + + public IndexSettingsAsSearchParams removeStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + return this; + } + + /** + * Removes stop (common) words from the query before executing it. + * + * @return removeStopWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Removes stop (common) words from the query before executing it." + ) + public String getRemoveStopWords() { + return removeStopWords; + } + + public void setRemoveStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + } + + public IndexSettingsAsSearchParams keepDiacriticsOnCharacters( + String keepDiacriticsOnCharacters + ) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + return this; + } + + /** + * List of characters that the engine shouldn’t automatically normalize. + * + * @return keepDiacriticsOnCharacters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of characters that the engine shouldn’t automatically normalize." + ) + public String getKeepDiacriticsOnCharacters() { + return keepDiacriticsOnCharacters; + } + + public void setKeepDiacriticsOnCharacters(String keepDiacriticsOnCharacters) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + } + + public IndexSettingsAsSearchParams queryLanguages( + List queryLanguages + ) { + this.queryLanguages = queryLanguages; + return this; + } + + public IndexSettingsAsSearchParams addQueryLanguagesItem( + String queryLanguagesItem + ) { + if (this.queryLanguages == null) { + this.queryLanguages = new ArrayList<>(); + } + this.queryLanguages.add(queryLanguagesItem); + return this; + } + + /** + * Sets the languages to be used by language-specific settings and functionalities such as + * ignorePlurals, removeStopWords, and CJK word-detection. + * + * @return queryLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Sets the languages to be used by language-specific settings and functionalities such as" + + " ignorePlurals, removeStopWords, and CJK word-detection." + ) + public List getQueryLanguages() { + return queryLanguages; + } + + public void setQueryLanguages(List queryLanguages) { + this.queryLanguages = queryLanguages; + } + + public IndexSettingsAsSearchParams decompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + return this; + } + + /** + * Splits compound words into their composing atoms in the query. + * + * @return decompoundQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Splits compound words into their composing atoms in the query." + ) + public Boolean getDecompoundQuery() { + return decompoundQuery; + } + + public void setDecompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + } + + public IndexSettingsAsSearchParams enableRules(Boolean enableRules) { + this.enableRules = enableRules; + return this; + } + + /** + * Whether Rules should be globally enabled. + * + * @return enableRules + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether Rules should be globally enabled.") + public Boolean getEnableRules() { + return enableRules; + } + + public void setEnableRules(Boolean enableRules) { + this.enableRules = enableRules; + } + + public IndexSettingsAsSearchParams enablePersonalization( + Boolean enablePersonalization + ) { + this.enablePersonalization = enablePersonalization; + return this; + } + + /** + * Enable the Personalization feature. + * + * @return enablePersonalization + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enable the Personalization feature.") + public Boolean getEnablePersonalization() { + return enablePersonalization; + } + + public void setEnablePersonalization(Boolean enablePersonalization) { + this.enablePersonalization = enablePersonalization; + } + + public IndexSettingsAsSearchParams queryType(QueryTypeEnum queryType) { + this.queryType = queryType; + return this; + } + + /** + * Controls if and how query words are interpreted as prefixes. + * + * @return queryType + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls if and how query words are interpreted as prefixes." + ) + public QueryTypeEnum getQueryType() { + return queryType; + } + + public void setQueryType(QueryTypeEnum queryType) { + this.queryType = queryType; + } + + public IndexSettingsAsSearchParams removeWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + return this; + } + + /** + * Selects a strategy to remove words from the query when it doesn’t match any hits. + * + * @return removeWordsIfNoResults + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Selects a strategy to remove words from the query when it doesn’t match any hits." + ) + public RemoveWordsIfNoResultsEnum getRemoveWordsIfNoResults() { + return removeWordsIfNoResults; + } + + public void setRemoveWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + } + + public IndexSettingsAsSearchParams advancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + return this; + } + + /** + * Enables the advanced query syntax. + * + * @return advancedSyntax + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables the advanced query syntax.") + public Boolean getAdvancedSyntax() { + return advancedSyntax; + } + + public void setAdvancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + } + + public IndexSettingsAsSearchParams optionalWords(List optionalWords) { + this.optionalWords = optionalWords; + return this; + } + + public IndexSettingsAsSearchParams addOptionalWordsItem( + String optionalWordsItem + ) { + if (this.optionalWords == null) { + this.optionalWords = new ArrayList<>(); + } + this.optionalWords.add(optionalWordsItem); + return this; + } + + /** + * A list of words that should be considered as optional when found in the query. + * + * @return optionalWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A list of words that should be considered as optional when found in the query." + ) + public List getOptionalWords() { + return optionalWords; + } + + public void setOptionalWords(List optionalWords) { + this.optionalWords = optionalWords; + } + + public IndexSettingsAsSearchParams disableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + return this; + } + + public IndexSettingsAsSearchParams addDisableExactOnAttributesItem( + String disableExactOnAttributesItem + ) { + if (this.disableExactOnAttributes == null) { + this.disableExactOnAttributes = new ArrayList<>(); + } + this.disableExactOnAttributes.add(disableExactOnAttributesItem); + return this; + } + + /** + * List of attributes on which you want to disable the exact ranking criterion. + * + * @return disableExactOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable the exact ranking criterion." + ) + public List getDisableExactOnAttributes() { + return disableExactOnAttributes; + } + + public void setDisableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + } + + public IndexSettingsAsSearchParams exactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + return this; + } + + /** + * Controls how the exact ranking criterion is computed when the query contains only one word. + * + * @return exactOnSingleWordQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls how the exact ranking criterion is computed when the query contains only one" + + " word." + ) + public ExactOnSingleWordQueryEnum getExactOnSingleWordQuery() { + return exactOnSingleWordQuery; + } + + public void setExactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + } + + public IndexSettingsAsSearchParams alternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + return this; + } + + public IndexSettingsAsSearchParams addAlternativesAsExactItem( + AlternativesAsExactEnum alternativesAsExactItem + ) { + if (this.alternativesAsExact == null) { + this.alternativesAsExact = new ArrayList<>(); + } + this.alternativesAsExact.add(alternativesAsExactItem); + return this; + } + + /** + * List of alternatives that should be considered an exact match by the exact ranking criterion. + * + * @return alternativesAsExact + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of alternatives that should be considered an exact match by the exact ranking" + + " criterion." + ) + public List getAlternativesAsExact() { + return alternativesAsExact; + } + + public void setAlternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + } + + public IndexSettingsAsSearchParams advancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + return this; + } + + public IndexSettingsAsSearchParams addAdvancedSyntaxFeaturesItem( + AdvancedSyntaxFeaturesEnum advancedSyntaxFeaturesItem + ) { + if (this.advancedSyntaxFeatures == null) { + this.advancedSyntaxFeatures = new ArrayList<>(); + } + this.advancedSyntaxFeatures.add(advancedSyntaxFeaturesItem); + return this; + } + + /** + * Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is + * enabled. + * + * @return advancedSyntaxFeatures + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is" + + " enabled." + ) + public List getAdvancedSyntaxFeatures() { + return advancedSyntaxFeatures; + } + + public void setAdvancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + } + + public IndexSettingsAsSearchParams distinct(Integer distinct) { + this.distinct = distinct; + return this; + } + + /** + * Enables de-duplication or grouping of results. minimum: 0 maximum: 4 + * + * @return distinct + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables de-duplication or grouping of results.") + public Integer getDistinct() { + return distinct; + } + + public void setDistinct(Integer distinct) { + this.distinct = distinct; + } + + public IndexSettingsAsSearchParams synonyms(Boolean synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Whether to take into account an index’s synonyms for a particular search. + * + * @return synonyms + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to take into account an index’s synonyms for a particular search." + ) + public Boolean getSynonyms() { + return synonyms; + } + + public void setSynonyms(Boolean synonyms) { + this.synonyms = synonyms; + } + + public IndexSettingsAsSearchParams replaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + return this; + } + + /** + * Whether to highlight and snippet the original word that matches the synonym or the synonym + * itself. + * + * @return replaceSynonymsInHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to highlight and snippet the original word that matches the synonym or the" + + " synonym itself." + ) + public Boolean getReplaceSynonymsInHighlight() { + return replaceSynonymsInHighlight; + } + + public void setReplaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + } + + public IndexSettingsAsSearchParams minProximity(Integer minProximity) { + this.minProximity = minProximity; + return this; + } + + /** + * Precision of the proximity ranking criterion. minimum: 1 maximum: 7 + * + * @return minProximity + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Precision of the proximity ranking criterion.") + public Integer getMinProximity() { + return minProximity; + } + + public void setMinProximity(Integer minProximity) { + this.minProximity = minProximity; + } + + public IndexSettingsAsSearchParams responseFields( + List responseFields + ) { + this.responseFields = responseFields; + return this; + } + + public IndexSettingsAsSearchParams addResponseFieldsItem( + String responseFieldsItem + ) { + if (this.responseFields == null) { + this.responseFields = new ArrayList<>(); + } + this.responseFields.add(responseFieldsItem); + return this; + } + + /** + * Choose which fields to return in the API response. This parameters applies to search and browse + * queries. + * + * @return responseFields + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Choose which fields to return in the API response. This parameters applies to search and" + + " browse queries." + ) + public List getResponseFields() { + return responseFields; + } + + public void setResponseFields(List responseFields) { + this.responseFields = responseFields; + } + + public IndexSettingsAsSearchParams maxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + return this; + } + + /** + * Maximum number of facet hits to return during a search for facet values. + * + * @return maxFacetHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet hits to return during a search for facet values." + ) + public Integer getMaxFacetHits() { + return maxFacetHits; + } + + public void setMaxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + } + + public IndexSettingsAsSearchParams attributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + return this; + } + + /** + * When attribute is ranked above proximity in your ranking formula, proximity is used to select + * which searchable attribute is matched in the attribute ranking stage. + * + * @return attributeCriteriaComputedByMinProximity + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "When attribute is ranked above proximity in your ranking formula, proximity is used to" + + " select which searchable attribute is matched in the attribute ranking stage." + ) + public Boolean getAttributeCriteriaComputedByMinProximity() { + return attributeCriteriaComputedByMinProximity; + } + + public void setAttributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + } + + public IndexSettingsAsSearchParams renderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + return this; + } + + /** + * Content defining how the search interface should be rendered. Can be set via the settings for a + * default value and can be overridden via rules. + * + * @return renderingContent + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Content defining how the search interface should be rendered. Can be set via the" + + " settings for a default value and can be overridden via rules." + ) + public Object getRenderingContent() { + return renderingContent; + } + + public void setRenderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + IndexSettingsAsSearchParams indexSettingsAsSearchParams = (IndexSettingsAsSearchParams) o; + return ( + Objects.equals( + this.searchableAttributes, + indexSettingsAsSearchParams.searchableAttributes + ) && + Objects.equals( + this.attributesForFaceting, + indexSettingsAsSearchParams.attributesForFaceting + ) && + Objects.equals( + this.unretrievableAttributes, + indexSettingsAsSearchParams.unretrievableAttributes + ) && + Objects.equals( + this.attributesToRetrieve, + indexSettingsAsSearchParams.attributesToRetrieve + ) && + Objects.equals( + this.restrictSearchableAttributes, + indexSettingsAsSearchParams.restrictSearchableAttributes + ) && + Objects.equals(this.ranking, indexSettingsAsSearchParams.ranking) && + Objects.equals( + this.customRanking, + indexSettingsAsSearchParams.customRanking + ) && + Objects.equals( + this.relevancyStrictness, + indexSettingsAsSearchParams.relevancyStrictness + ) && + Objects.equals( + this.attributesToHighlight, + indexSettingsAsSearchParams.attributesToHighlight + ) && + Objects.equals( + this.attributesToSnippet, + indexSettingsAsSearchParams.attributesToSnippet + ) && + Objects.equals( + this.highlightPreTag, + indexSettingsAsSearchParams.highlightPreTag + ) && + Objects.equals( + this.highlightPostTag, + indexSettingsAsSearchParams.highlightPostTag + ) && + Objects.equals( + this.snippetEllipsisText, + indexSettingsAsSearchParams.snippetEllipsisText + ) && + Objects.equals( + this.restrictHighlightAndSnippetArrays, + indexSettingsAsSearchParams.restrictHighlightAndSnippetArrays + ) && + Objects.equals( + this.hitsPerPage, + indexSettingsAsSearchParams.hitsPerPage + ) && + Objects.equals( + this.minWordSizefor1Typo, + indexSettingsAsSearchParams.minWordSizefor1Typo + ) && + Objects.equals( + this.minWordSizefor2Typos, + indexSettingsAsSearchParams.minWordSizefor2Typos + ) && + Objects.equals( + this.typoTolerance, + indexSettingsAsSearchParams.typoTolerance + ) && + Objects.equals( + this.allowTyposOnNumericTokens, + indexSettingsAsSearchParams.allowTyposOnNumericTokens + ) && + Objects.equals( + this.disableTypoToleranceOnAttributes, + indexSettingsAsSearchParams.disableTypoToleranceOnAttributes + ) && + Objects.equals( + this.separatorsToIndex, + indexSettingsAsSearchParams.separatorsToIndex + ) && + Objects.equals( + this.ignorePlurals, + indexSettingsAsSearchParams.ignorePlurals + ) && + Objects.equals( + this.removeStopWords, + indexSettingsAsSearchParams.removeStopWords + ) && + Objects.equals( + this.keepDiacriticsOnCharacters, + indexSettingsAsSearchParams.keepDiacriticsOnCharacters + ) && + Objects.equals( + this.queryLanguages, + indexSettingsAsSearchParams.queryLanguages + ) && + Objects.equals( + this.decompoundQuery, + indexSettingsAsSearchParams.decompoundQuery + ) && + Objects.equals( + this.enableRules, + indexSettingsAsSearchParams.enableRules + ) && + Objects.equals( + this.enablePersonalization, + indexSettingsAsSearchParams.enablePersonalization + ) && + Objects.equals(this.queryType, indexSettingsAsSearchParams.queryType) && + Objects.equals( + this.removeWordsIfNoResults, + indexSettingsAsSearchParams.removeWordsIfNoResults + ) && + Objects.equals( + this.advancedSyntax, + indexSettingsAsSearchParams.advancedSyntax + ) && + Objects.equals( + this.optionalWords, + indexSettingsAsSearchParams.optionalWords + ) && + Objects.equals( + this.disableExactOnAttributes, + indexSettingsAsSearchParams.disableExactOnAttributes + ) && + Objects.equals( + this.exactOnSingleWordQuery, + indexSettingsAsSearchParams.exactOnSingleWordQuery + ) && + Objects.equals( + this.alternativesAsExact, + indexSettingsAsSearchParams.alternativesAsExact + ) && + Objects.equals( + this.advancedSyntaxFeatures, + indexSettingsAsSearchParams.advancedSyntaxFeatures + ) && + Objects.equals(this.distinct, indexSettingsAsSearchParams.distinct) && + Objects.equals(this.synonyms, indexSettingsAsSearchParams.synonyms) && + Objects.equals( + this.replaceSynonymsInHighlight, + indexSettingsAsSearchParams.replaceSynonymsInHighlight + ) && + Objects.equals( + this.minProximity, + indexSettingsAsSearchParams.minProximity + ) && + Objects.equals( + this.responseFields, + indexSettingsAsSearchParams.responseFields + ) && + Objects.equals( + this.maxFacetHits, + indexSettingsAsSearchParams.maxFacetHits + ) && + Objects.equals( + this.attributeCriteriaComputedByMinProximity, + indexSettingsAsSearchParams.attributeCriteriaComputedByMinProximity + ) && + Objects.equals( + this.renderingContent, + indexSettingsAsSearchParams.renderingContent + ) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + searchableAttributes, + attributesForFaceting, + unretrievableAttributes, + attributesToRetrieve, + restrictSearchableAttributes, + ranking, + customRanking, + relevancyStrictness, + attributesToHighlight, + attributesToSnippet, + highlightPreTag, + highlightPostTag, + snippetEllipsisText, + restrictHighlightAndSnippetArrays, + hitsPerPage, + minWordSizefor1Typo, + minWordSizefor2Typos, + typoTolerance, + allowTyposOnNumericTokens, + disableTypoToleranceOnAttributes, + separatorsToIndex, + ignorePlurals, + removeStopWords, + keepDiacriticsOnCharacters, + queryLanguages, + decompoundQuery, + enableRules, + enablePersonalization, + queryType, + removeWordsIfNoResults, + advancedSyntax, + optionalWords, + disableExactOnAttributes, + exactOnSingleWordQuery, + alternativesAsExact, + advancedSyntaxFeatures, + distinct, + synonyms, + replaceSynonymsInHighlight, + minProximity, + responseFields, + maxFacetHits, + attributeCriteriaComputedByMinProximity, + renderingContent + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class IndexSettingsAsSearchParams {\n"); + sb + .append(" searchableAttributes: ") + .append(toIndentedString(searchableAttributes)) + .append("\n"); + sb + .append(" attributesForFaceting: ") + .append(toIndentedString(attributesForFaceting)) + .append("\n"); + sb + .append(" unretrievableAttributes: ") + .append(toIndentedString(unretrievableAttributes)) + .append("\n"); + sb + .append(" attributesToRetrieve: ") + .append(toIndentedString(attributesToRetrieve)) + .append("\n"); + sb + .append(" restrictSearchableAttributes: ") + .append(toIndentedString(restrictSearchableAttributes)) + .append("\n"); + sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n"); + sb + .append(" customRanking: ") + .append(toIndentedString(customRanking)) + .append("\n"); + sb + .append(" relevancyStrictness: ") + .append(toIndentedString(relevancyStrictness)) + .append("\n"); + sb + .append(" attributesToHighlight: ") + .append(toIndentedString(attributesToHighlight)) + .append("\n"); + sb + .append(" attributesToSnippet: ") + .append(toIndentedString(attributesToSnippet)) + .append("\n"); + sb + .append(" highlightPreTag: ") + .append(toIndentedString(highlightPreTag)) + .append("\n"); + sb + .append(" highlightPostTag: ") + .append(toIndentedString(highlightPostTag)) + .append("\n"); + sb + .append(" snippetEllipsisText: ") + .append(toIndentedString(snippetEllipsisText)) + .append("\n"); + sb + .append(" restrictHighlightAndSnippetArrays: ") + .append(toIndentedString(restrictHighlightAndSnippetArrays)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb + .append(" minWordSizefor1Typo: ") + .append(toIndentedString(minWordSizefor1Typo)) + .append("\n"); + sb + .append(" minWordSizefor2Typos: ") + .append(toIndentedString(minWordSizefor2Typos)) + .append("\n"); + sb + .append(" typoTolerance: ") + .append(toIndentedString(typoTolerance)) + .append("\n"); + sb + .append(" allowTyposOnNumericTokens: ") + .append(toIndentedString(allowTyposOnNumericTokens)) + .append("\n"); + sb + .append(" disableTypoToleranceOnAttributes: ") + .append(toIndentedString(disableTypoToleranceOnAttributes)) + .append("\n"); + sb + .append(" separatorsToIndex: ") + .append(toIndentedString(separatorsToIndex)) + .append("\n"); + sb + .append(" ignorePlurals: ") + .append(toIndentedString(ignorePlurals)) + .append("\n"); + sb + .append(" removeStopWords: ") + .append(toIndentedString(removeStopWords)) + .append("\n"); + sb + .append(" keepDiacriticsOnCharacters: ") + .append(toIndentedString(keepDiacriticsOnCharacters)) + .append("\n"); + sb + .append(" queryLanguages: ") + .append(toIndentedString(queryLanguages)) + .append("\n"); + sb + .append(" decompoundQuery: ") + .append(toIndentedString(decompoundQuery)) + .append("\n"); + sb + .append(" enableRules: ") + .append(toIndentedString(enableRules)) + .append("\n"); + sb + .append(" enablePersonalization: ") + .append(toIndentedString(enablePersonalization)) + .append("\n"); + sb + .append(" queryType: ") + .append(toIndentedString(queryType)) + .append("\n"); + sb + .append(" removeWordsIfNoResults: ") + .append(toIndentedString(removeWordsIfNoResults)) + .append("\n"); + sb + .append(" advancedSyntax: ") + .append(toIndentedString(advancedSyntax)) + .append("\n"); + sb + .append(" optionalWords: ") + .append(toIndentedString(optionalWords)) + .append("\n"); + sb + .append(" disableExactOnAttributes: ") + .append(toIndentedString(disableExactOnAttributes)) + .append("\n"); + sb + .append(" exactOnSingleWordQuery: ") + .append(toIndentedString(exactOnSingleWordQuery)) + .append("\n"); + sb + .append(" alternativesAsExact: ") + .append(toIndentedString(alternativesAsExact)) + .append("\n"); + sb + .append(" advancedSyntaxFeatures: ") + .append(toIndentedString(advancedSyntaxFeatures)) + .append("\n"); + sb.append(" distinct: ").append(toIndentedString(distinct)).append("\n"); + sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n"); + sb + .append(" replaceSynonymsInHighlight: ") + .append(toIndentedString(replaceSynonymsInHighlight)) + .append("\n"); + sb + .append(" minProximity: ") + .append(toIndentedString(minProximity)) + .append("\n"); + sb + .append(" responseFields: ") + .append(toIndentedString(responseFields)) + .append("\n"); + sb + .append(" maxFacetHits: ") + .append(toIndentedString(maxFacetHits)) + .append("\n"); + sb + .append(" attributeCriteriaComputedByMinProximity: ") + .append(toIndentedString(attributeCriteriaComputedByMinProximity)) + .append("\n"); + sb + .append(" renderingContent: ") + .append(toIndentedString(renderingContent)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ListIndicesResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ListIndicesResponse.java new file mode 100644 index 00000000000..201e4d3634d --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/ListIndicesResponse.java @@ -0,0 +1,109 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** ListIndicesResponse */ +public class ListIndicesResponse { + + public static final String SERIALIZED_NAME_ITEMS = "items"; + + @SerializedName(SERIALIZED_NAME_ITEMS) + private List items = null; + + public static final String SERIALIZED_NAME_NB_PAGES = "nbPages"; + + @SerializedName(SERIALIZED_NAME_NB_PAGES) + private Integer nbPages; + + public ListIndicesResponse items(List items) { + this.items = items; + return this; + } + + public ListIndicesResponse addItemsItem(Index itemsItem) { + if (this.items == null) { + this.items = new ArrayList<>(); + } + this.items.add(itemsItem); + return this; + } + + /** + * List of the fetched indices. + * + * @return items + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of the fetched indices.") + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public ListIndicesResponse nbPages(Integer nbPages) { + this.nbPages = nbPages; + return this; + } + + /** + * Number of pages. + * + * @return nbPages + */ + @javax.annotation.Nullable + @ApiModelProperty(example = "100", value = "Number of pages.") + public Integer getNbPages() { + return nbPages; + } + + public void setNbPages(Integer nbPages) { + this.nbPages = nbPages; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListIndicesResponse listIndicesResponse = (ListIndicesResponse) o; + return ( + Objects.equals(this.items, listIndicesResponse.items) && + Objects.equals(this.nbPages, listIndicesResponse.nbPages) + ); + } + + @Override + public int hashCode() { + return Objects.hash(items, nbPages); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListIndicesResponse {\n"); + sb.append(" items: ").append(toIndentedString(items)).append("\n"); + sb.append(" nbPages: ").append(toIndentedString(nbPages)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueries.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueries.java new file mode 100644 index 00000000000..f7cd5d23f09 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueries.java @@ -0,0 +1,244 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.Objects; + +/** MultipleQueries */ +public class MultipleQueries { + + public static final String SERIALIZED_NAME_INDEX_NAME = "indexName"; + + @SerializedName(SERIALIZED_NAME_INDEX_NAME) + private String indexName; + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + /** Perform a search query with `default`, will search for facet values if `facet` is given. */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + DEFAULT("default"), + + FACET("facet"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final TypeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type = TypeEnum.DEFAULT; + + public static final String SERIALIZED_NAME_FACET = "facet"; + + @SerializedName(SERIALIZED_NAME_FACET) + private String facet; + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params; + + public MultipleQueries indexName(String indexName) { + this.indexName = indexName; + return this; + } + + /** + * The Algolia index name. + * + * @return indexName + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "products", + required = true, + value = "The Algolia index name." + ) + public String getIndexName() { + return indexName; + } + + public void setIndexName(String indexName) { + this.indexName = indexName; + } + + public MultipleQueries query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public MultipleQueries type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Perform a search query with `default`, will search for facet values if `facet` is given. + * + * @return type + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Perform a search query with `default`, will search for facet values if `facet` is" + + " given." + ) + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public MultipleQueries facet(String facet) { + this.facet = facet; + return this; + } + + /** + * The `facet` name. + * + * @return facet + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The `facet` name.") + public String getFacet() { + return facet; + } + + public void setFacet(String facet) { + this.facet = facet; + } + + public MultipleQueries params(String params) { + this.params = params; + return this; + } + + /** + * A query string of search parameters. + * + * @return params + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "A query string of search parameters.") + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultipleQueries multipleQueries = (MultipleQueries) o; + return ( + Objects.equals(this.indexName, multipleQueries.indexName) && + Objects.equals(this.query, multipleQueries.query) && + Objects.equals(this.type, multipleQueries.type) && + Objects.equals(this.facet, multipleQueries.facet) && + Objects.equals(this.params, multipleQueries.params) + ); + } + + @Override + public int hashCode() { + return Objects.hash(indexName, query, type, facet, params); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultipleQueries {\n"); + sb + .append(" indexName: ") + .append(toIndentedString(indexName)) + .append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" facet: ").append(toIndentedString(facet)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesObject.java new file mode 100644 index 00000000000..f799ac1ac0f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesObject.java @@ -0,0 +1,160 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** MultipleQueriesObject */ +public class MultipleQueriesObject { + + public static final String SERIALIZED_NAME_REQUESTS = "requests"; + + @SerializedName(SERIALIZED_NAME_REQUESTS) + private List requests = new ArrayList<>(); + + /** Gets or Sets strategy */ + @JsonAdapter(StrategyEnum.Adapter.class) + public enum StrategyEnum { + NONE("none"), + + STOPIFENOUGHMATCHES("stopIfEnoughMatches"); + + private String value; + + StrategyEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static StrategyEnum fromValue(String value) { + for (StrategyEnum b : StrategyEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final StrategyEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public StrategyEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return StrategyEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_STRATEGY = "strategy"; + + @SerializedName(SERIALIZED_NAME_STRATEGY) + private StrategyEnum strategy; + + public MultipleQueriesObject requests(List requests) { + this.requests = requests; + return this; + } + + public MultipleQueriesObject addRequestsItem(MultipleQueries requestsItem) { + this.requests.add(requestsItem); + return this; + } + + /** + * Get requests + * + * @return requests + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + public List getRequests() { + return requests; + } + + public void setRequests(List requests) { + this.requests = requests; + } + + public MultipleQueriesObject strategy(StrategyEnum strategy) { + this.strategy = strategy; + return this; + } + + /** + * Get strategy + * + * @return strategy + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public StrategyEnum getStrategy() { + return strategy; + } + + public void setStrategy(StrategyEnum strategy) { + this.strategy = strategy; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultipleQueriesObject multipleQueriesObject = (MultipleQueriesObject) o; + return ( + Objects.equals(this.requests, multipleQueriesObject.requests) && + Objects.equals(this.strategy, multipleQueriesObject.strategy) + ); + } + + @Override + public int hashCode() { + return Objects.hash(requests, strategy); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultipleQueriesObject {\n"); + sb.append(" requests: ").append(toIndentedString(requests)).append("\n"); + sb.append(" strategy: ").append(toIndentedString(strategy)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesResponse.java new file mode 100644 index 00000000000..c9818f862b3 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/MultipleQueriesResponse.java @@ -0,0 +1,80 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** MultipleQueriesResponse */ +public class MultipleQueriesResponse { + + public static final String SERIALIZED_NAME_RESULTS = "results"; + + @SerializedName(SERIALIZED_NAME_RESULTS) + private List results = null; + + public MultipleQueriesResponse results(List results) { + this.results = results; + return this; + } + + public MultipleQueriesResponse addResultsItem(SearchResponse resultsItem) { + if (this.results == null) { + this.results = new ArrayList<>(); + } + this.results.add(resultsItem); + return this; + } + + /** + * Get results + * + * @return results + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MultipleQueriesResponse multipleQueriesResponse = (MultipleQueriesResponse) o; + return Objects.equals(this.results, multipleQueriesResponse.results); + } + + @Override + public int hashCode() { + return Objects.hash(results); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class MultipleQueriesResponse {\n"); + sb.append(" results: ").append(toIndentedString(results)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OneOfintegerstring.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OneOfintegerstring.java new file mode 100644 index 00000000000..00156b31400 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OneOfintegerstring.java @@ -0,0 +1,3 @@ +package com.algolia.model; + +public class OneOfintegerstring {} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java new file mode 100644 index 00000000000..269dc3d26d9 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Operation.java @@ -0,0 +1,175 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** Operation */ +public class Operation { + + /** type of operation. */ + @JsonAdapter(ActionEnum.Adapter.class) + public enum ActionEnum { + ADDOBJECT("addObject"), + + UPDATEOBJECT("updateObject"), + + PARTIALUPDATEOBJECT("partialUpdateObject"), + + PARTIALUPDATEOBJECTNOCREATE("partialUpdateObjectNoCreate"), + + DELETEOBJECT("deleteObject"), + + DELETE("delete"), + + CLEAR("clear"); + + private String value; + + ActionEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ActionEnum fromValue(String value) { + for (ActionEnum b : ActionEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final ActionEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ActionEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ActionEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ACTION = "action"; + + @SerializedName(SERIALIZED_NAME_ACTION) + private ActionEnum action; + + public static final String SERIALIZED_NAME_BODY = "body"; + + @SerializedName(SERIALIZED_NAME_BODY) + private Map body = null; + + public Operation action(ActionEnum action) { + this.action = action; + return this; + } + + /** + * type of operation. + * + * @return action + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "type of operation.") + public ActionEnum getAction() { + return action; + } + + public void setAction(ActionEnum action) { + this.action = action; + } + + public Operation body(Map body) { + this.body = body; + return this; + } + + public Operation putBodyItem(String key, Object bodyItem) { + if (this.body == null) { + this.body = new HashMap<>(); + } + this.body.put(key, bodyItem); + return this; + } + + /** + * arguments to the operation (depends on the type of the operation). + * + * @return body + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "arguments to the operation (depends on the type of the operation)." + ) + public Map getBody() { + return body; + } + + public void setBody(Map body) { + this.body = body; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Operation operation = (Operation) o; + return ( + Objects.equals(this.action, operation.action) && + Objects.equals(this.body, operation.body) + ); + } + + @Override + public int hashCode() { + return Objects.hash(action, body); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Operation {\n"); + sb.append(" action: ").append(toIndentedString(action)).append("\n"); + sb.append(" body: ").append(toIndentedString(body)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexObject.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexObject.java new file mode 100644 index 00000000000..c7bc64aa54d --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexObject.java @@ -0,0 +1,259 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** OperationIndexObject */ +public class OperationIndexObject { + + /** Type of operation to perform (move or copy). */ + @JsonAdapter(OperationEnum.Adapter.class) + public enum OperationEnum { + MOVE("move"), + + COPY("copy"); + + private String value; + + OperationEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static OperationEnum fromValue(String value) { + for (OperationEnum b : OperationEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final OperationEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public OperationEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return OperationEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_OPERATION = "operation"; + + @SerializedName(SERIALIZED_NAME_OPERATION) + private OperationEnum operation; + + public static final String SERIALIZED_NAME_DESTINATION = "destination"; + + @SerializedName(SERIALIZED_NAME_DESTINATION) + private String destination; + + /** Gets or Sets scope */ + @JsonAdapter(ScopeEnum.Adapter.class) + public enum ScopeEnum { + SETTINGS("settings"), + + SYNONYMS("synonyms"), + + RULES("rules"); + + private String value; + + ScopeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ScopeEnum fromValue(String value) { + for (ScopeEnum b : ScopeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final ScopeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ScopeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return ScopeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_SCOPE = "scope"; + + @SerializedName(SERIALIZED_NAME_SCOPE) + private List scope = null; + + public OperationIndexObject operation(OperationEnum operation) { + this.operation = operation; + return this; + } + + /** + * Type of operation to perform (move or copy). + * + * @return operation + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Type of operation to perform (move or copy)." + ) + public OperationEnum getOperation() { + return operation; + } + + public void setOperation(OperationEnum operation) { + this.operation = operation; + } + + public OperationIndexObject destination(String destination) { + this.destination = destination; + return this; + } + + /** + * The Algolia index name. + * + * @return destination + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "products", + required = true, + value = "The Algolia index name." + ) + public String getDestination() { + return destination; + } + + public void setDestination(String destination) { + this.destination = destination; + } + + public OperationIndexObject scope(List scope) { + this.scope = scope; + return this; + } + + public OperationIndexObject addScopeItem(ScopeEnum scopeItem) { + if (this.scope == null) { + this.scope = new ArrayList<>(); + } + this.scope.add(scopeItem); + return this; + } + + /** + * Scope of the data to copy. When absent, a full copy is performed. When present, only the + * selected scopes are copied. + * + * @return scope + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Scope of the data to copy. When absent, a full copy is performed. When present, only the" + + " selected scopes are copied." + ) + public List getScope() { + return scope; + } + + public void setScope(List scope) { + this.scope = scope; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationIndexObject operationIndexObject = (OperationIndexObject) o; + return ( + Objects.equals(this.operation, operationIndexObject.operation) && + Objects.equals(this.destination, operationIndexObject.destination) && + Objects.equals(this.scope, operationIndexObject.scope) + ); + } + + @Override + public int hashCode() { + return Objects.hash(operation, destination, scope); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationIndexObject {\n"); + sb + .append(" operation: ") + .append(toIndentedString(operation)) + .append("\n"); + sb + .append(" destination: ") + .append(toIndentedString(destination)) + .append("\n"); + sb.append(" scope: ").append(toIndentedString(scope)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexResponse.java new file mode 100644 index 00000000000..0a4b6bb2528 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/OperationIndexResponse.java @@ -0,0 +1,103 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** OperationIndexResponse */ +public class OperationIndexResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public OperationIndexResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "taskID of the indexing task to wait for.") + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public OperationIndexResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Date of last update (ISO-8601 format).") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + OperationIndexResponse operationIndexResponse = (OperationIndexResponse) o; + return ( + Objects.equals(this.taskID, operationIndexResponse.taskID) && + Objects.equals(this.updatedAt, operationIndexResponse.updatedAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class OperationIndexResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfo.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfo.java new file mode 100644 index 00000000000..ca84786ff7f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfo.java @@ -0,0 +1,415 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; + +/** RankingInfo */ +public class RankingInfo { + + public static final String SERIALIZED_NAME_FILTERS = "filters"; + + @SerializedName(SERIALIZED_NAME_FILTERS) + private Integer filters; + + public static final String SERIALIZED_NAME_FIRST_MATCHED_WORD = + "firstMatchedWord"; + + @SerializedName(SERIALIZED_NAME_FIRST_MATCHED_WORD) + private Integer firstMatchedWord; + + public static final String SERIALIZED_NAME_GEO_DISTANCE = "geoDistance"; + + @SerializedName(SERIALIZED_NAME_GEO_DISTANCE) + private Integer geoDistance; + + public static final String SERIALIZED_NAME_GEO_PRECISION = "geoPrecision"; + + @SerializedName(SERIALIZED_NAME_GEO_PRECISION) + private Integer geoPrecision; + + public static final String SERIALIZED_NAME_MATCHED_GEO_LOCATION = + "matchedGeoLocation"; + + @SerializedName(SERIALIZED_NAME_MATCHED_GEO_LOCATION) + private Map matchedGeoLocation = null; + + public static final String SERIALIZED_NAME_NB_EXACT_WORDS = "nbExactWords"; + + @SerializedName(SERIALIZED_NAME_NB_EXACT_WORDS) + private Integer nbExactWords; + + public static final String SERIALIZED_NAME_NB_TYPOS = "nbTypos"; + + @SerializedName(SERIALIZED_NAME_NB_TYPOS) + private Integer nbTypos; + + public static final String SERIALIZED_NAME_PROMOTED = "promoted"; + + @SerializedName(SERIALIZED_NAME_PROMOTED) + private Boolean promoted; + + public static final String SERIALIZED_NAME_PROXIMITY_DISTANCE = + "proximityDistance"; + + @SerializedName(SERIALIZED_NAME_PROXIMITY_DISTANCE) + private Integer proximityDistance; + + public static final String SERIALIZED_NAME_USER_SCORE = "userScore"; + + @SerializedName(SERIALIZED_NAME_USER_SCORE) + private Integer userScore; + + public static final String SERIALIZED_NAME_WORD = "word"; + + @SerializedName(SERIALIZED_NAME_WORD) + private Integer word; + + public RankingInfo filters(Integer filters) { + this.filters = filters; + return this; + } + + /** + * This field is reserved for advanced usage. + * + * @return filters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "This field is reserved for advanced usage.") + public Integer getFilters() { + return filters; + } + + public void setFilters(Integer filters) { + this.filters = filters; + } + + public RankingInfo firstMatchedWord(Integer firstMatchedWord) { + this.firstMatchedWord = firstMatchedWord; + return this; + } + + /** + * Position of the most important matched attribute in the attributes to index list. + * + * @return firstMatchedWord + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Position of the most important matched attribute in the attributes to index list." + ) + public Integer getFirstMatchedWord() { + return firstMatchedWord; + } + + public void setFirstMatchedWord(Integer firstMatchedWord) { + this.firstMatchedWord = firstMatchedWord; + } + + public RankingInfo geoDistance(Integer geoDistance) { + this.geoDistance = geoDistance; + return this; + } + + /** + * Distance between the geo location in the search query and the best matching geo location in the + * record, divided by the geo precision (in meters). + * + * @return geoDistance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Distance between the geo location in the search query and the best matching geo location" + + " in the record, divided by the geo precision (in meters)." + ) + public Integer getGeoDistance() { + return geoDistance; + } + + public void setGeoDistance(Integer geoDistance) { + this.geoDistance = geoDistance; + } + + public RankingInfo geoPrecision(Integer geoPrecision) { + this.geoPrecision = geoPrecision; + return this; + } + + /** + * Precision used when computing the geo distance, in meters. + * + * @return geoPrecision + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Precision used when computing the geo distance, in meters." + ) + public Integer getGeoPrecision() { + return geoPrecision; + } + + public void setGeoPrecision(Integer geoPrecision) { + this.geoPrecision = geoPrecision; + } + + public RankingInfo matchedGeoLocation( + Map matchedGeoLocation + ) { + this.matchedGeoLocation = matchedGeoLocation; + return this; + } + + public RankingInfo putMatchedGeoLocationItem( + String key, + RankingInfoMatchedGeoLocation matchedGeoLocationItem + ) { + if (this.matchedGeoLocation == null) { + this.matchedGeoLocation = new HashMap<>(); + } + this.matchedGeoLocation.put(key, matchedGeoLocationItem); + return this; + } + + /** + * Get matchedGeoLocation + * + * @return matchedGeoLocation + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public Map getMatchedGeoLocation() { + return matchedGeoLocation; + } + + public void setMatchedGeoLocation( + Map matchedGeoLocation + ) { + this.matchedGeoLocation = matchedGeoLocation; + } + + public RankingInfo nbExactWords(Integer nbExactWords) { + this.nbExactWords = nbExactWords; + return this; + } + + /** + * Number of exactly matched words. + * + * @return nbExactWords + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Number of exactly matched words.") + public Integer getNbExactWords() { + return nbExactWords; + } + + public void setNbExactWords(Integer nbExactWords) { + this.nbExactWords = nbExactWords; + } + + public RankingInfo nbTypos(Integer nbTypos) { + this.nbTypos = nbTypos; + return this; + } + + /** + * Number of typos encountered when matching the record. + * + * @return nbTypos + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Number of typos encountered when matching the record." + ) + public Integer getNbTypos() { + return nbTypos; + } + + public void setNbTypos(Integer nbTypos) { + this.nbTypos = nbTypos; + } + + public RankingInfo promoted(Boolean promoted) { + this.promoted = promoted; + return this; + } + + /** + * Present and set to true if a Rule promoted the hit. + * + * @return promoted + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Present and set to true if a Rule promoted the hit." + ) + public Boolean getPromoted() { + return promoted; + } + + public void setPromoted(Boolean promoted) { + this.promoted = promoted; + } + + public RankingInfo proximityDistance(Integer proximityDistance) { + this.proximityDistance = proximityDistance; + return this; + } + + /** + * When the query contains more than one word, the sum of the distances between matched words (in + * meters). + * + * @return proximityDistance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "When the query contains more than one word, the sum of the distances between matched" + + " words (in meters)." + ) + public Integer getProximityDistance() { + return proximityDistance; + } + + public void setProximityDistance(Integer proximityDistance) { + this.proximityDistance = proximityDistance; + } + + public RankingInfo userScore(Integer userScore) { + this.userScore = userScore; + return this; + } + + /** + * Custom ranking for the object, expressed as a single integer value. + * + * @return userScore + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Custom ranking for the object, expressed as a single integer value." + ) + public Integer getUserScore() { + return userScore; + } + + public void setUserScore(Integer userScore) { + this.userScore = userScore; + } + + public RankingInfo word(Integer word) { + this.word = word; + return this; + } + + /** + * Number of matched words, including prefixes and typos. + * + * @return word + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Number of matched words, including prefixes and typos." + ) + public Integer getWord() { + return word; + } + + public void setWord(Integer word) { + this.word = word; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RankingInfo rankingInfo = (RankingInfo) o; + return ( + Objects.equals(this.filters, rankingInfo.filters) && + Objects.equals(this.firstMatchedWord, rankingInfo.firstMatchedWord) && + Objects.equals(this.geoDistance, rankingInfo.geoDistance) && + Objects.equals(this.geoPrecision, rankingInfo.geoPrecision) && + Objects.equals(this.matchedGeoLocation, rankingInfo.matchedGeoLocation) && + Objects.equals(this.nbExactWords, rankingInfo.nbExactWords) && + Objects.equals(this.nbTypos, rankingInfo.nbTypos) && + Objects.equals(this.promoted, rankingInfo.promoted) && + Objects.equals(this.proximityDistance, rankingInfo.proximityDistance) && + Objects.equals(this.userScore, rankingInfo.userScore) && + Objects.equals(this.word, rankingInfo.word) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + filters, + firstMatchedWord, + geoDistance, + geoPrecision, + matchedGeoLocation, + nbExactWords, + nbTypos, + promoted, + proximityDistance, + userScore, + word + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RankingInfo {\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb + .append(" firstMatchedWord: ") + .append(toIndentedString(firstMatchedWord)) + .append("\n"); + sb + .append(" geoDistance: ") + .append(toIndentedString(geoDistance)) + .append("\n"); + sb + .append(" geoPrecision: ") + .append(toIndentedString(geoPrecision)) + .append("\n"); + sb + .append(" matchedGeoLocation: ") + .append(toIndentedString(matchedGeoLocation)) + .append("\n"); + sb + .append(" nbExactWords: ") + .append(toIndentedString(nbExactWords)) + .append("\n"); + sb.append(" nbTypos: ").append(toIndentedString(nbTypos)).append("\n"); + sb.append(" promoted: ").append(toIndentedString(promoted)).append("\n"); + sb + .append(" proximityDistance: ") + .append(toIndentedString(proximityDistance)) + .append("\n"); + sb + .append(" userScore: ") + .append(toIndentedString(userScore)) + .append("\n"); + sb.append(" word: ").append(toIndentedString(word)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfoMatchedGeoLocation.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfoMatchedGeoLocation.java new file mode 100644 index 00000000000..9007f515dc4 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/RankingInfoMatchedGeoLocation.java @@ -0,0 +1,128 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** RankingInfoMatchedGeoLocation */ +public class RankingInfoMatchedGeoLocation { + + public static final String SERIALIZED_NAME_LAT = "lat"; + + @SerializedName(SERIALIZED_NAME_LAT) + private Double lat; + + public static final String SERIALIZED_NAME_LNG = "lng"; + + @SerializedName(SERIALIZED_NAME_LNG) + private Double lng; + + public static final String SERIALIZED_NAME_DISTANCE = "distance"; + + @SerializedName(SERIALIZED_NAME_DISTANCE) + private Integer distance; + + public RankingInfoMatchedGeoLocation lat(Double lat) { + this.lat = lat; + return this; + } + + /** + * Latitude of the matched location. + * + * @return lat + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Latitude of the matched location.") + public Double getLat() { + return lat; + } + + public void setLat(Double lat) { + this.lat = lat; + } + + public RankingInfoMatchedGeoLocation lng(Double lng) { + this.lng = lng; + return this; + } + + /** + * Longitude of the matched location. + * + * @return lng + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Longitude of the matched location.") + public Double getLng() { + return lng; + } + + public void setLng(Double lng) { + this.lng = lng; + } + + public RankingInfoMatchedGeoLocation distance(Integer distance) { + this.distance = distance; + return this; + } + + /** + * Distance between the matched location and the search location (in meters). + * + * @return distance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Distance between the matched location and the search location (in meters)." + ) + public Integer getDistance() { + return distance; + } + + public void setDistance(Integer distance) { + this.distance = distance; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + RankingInfoMatchedGeoLocation rankingInfoMatchedGeoLocation = (RankingInfoMatchedGeoLocation) o; + return ( + Objects.equals(this.lat, rankingInfoMatchedGeoLocation.lat) && + Objects.equals(this.lng, rankingInfoMatchedGeoLocation.lng) && + Objects.equals(this.distance, rankingInfoMatchedGeoLocation.distance) + ); + } + + @Override + public int hashCode() { + return Objects.hash(lat, lng, distance); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RankingInfoMatchedGeoLocation {\n"); + sb.append(" lat: ").append(toIndentedString(lat)).append("\n"); + sb.append(" lng: ").append(toIndentedString(lng)).append("\n"); + sb.append(" distance: ").append(toIndentedString(distance)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Record.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Record.java new file mode 100644 index 00000000000..c077f4165f5 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/Record.java @@ -0,0 +1,206 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.HashMap; +import java.util.Objects; + +/** A single record. */ +@ApiModel(description = "A single record.") +public class Record extends HashMap { + + public static final String SERIALIZED_NAME_OBJECT_I_D = "objectID"; + + @SerializedName(SERIALIZED_NAME_OBJECT_I_D) + private String objectID; + + public static final String SERIALIZED_NAME_HIGHLIGHT_RESULT = + "_highlightResult"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_RESULT) + private HighlightResult highlightResult; + + public static final String SERIALIZED_NAME_SNIPPET_RESULT = "_snippetResult"; + + @SerializedName(SERIALIZED_NAME_SNIPPET_RESULT) + private SnippetResult snippetResult; + + public static final String SERIALIZED_NAME_RANKING_INFO = "_rankingInfo"; + + @SerializedName(SERIALIZED_NAME_RANKING_INFO) + private RankingInfo rankingInfo; + + public static final String SERIALIZED_NAME_DISTINCT_SEQ_I_D = + "_distinctSeqID"; + + @SerializedName(SERIALIZED_NAME_DISTINCT_SEQ_I_D) + private Integer distinctSeqID; + + public Record objectID(String objectID) { + this.objectID = objectID; + return this; + } + + /** + * Unique identifier of the object. + * + * @return objectID + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Unique identifier of the object.") + public String getObjectID() { + return objectID; + } + + public void setObjectID(String objectID) { + this.objectID = objectID; + } + + public Record highlightResult(HighlightResult highlightResult) { + this.highlightResult = highlightResult; + return this; + } + + /** + * Get highlightResult + * + * @return highlightResult + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public HighlightResult getHighlightResult() { + return highlightResult; + } + + public void setHighlightResult(HighlightResult highlightResult) { + this.highlightResult = highlightResult; + } + + public Record snippetResult(SnippetResult snippetResult) { + this.snippetResult = snippetResult; + return this; + } + + /** + * Get snippetResult + * + * @return snippetResult + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public SnippetResult getSnippetResult() { + return snippetResult; + } + + public void setSnippetResult(SnippetResult snippetResult) { + this.snippetResult = snippetResult; + } + + public Record rankingInfo(RankingInfo rankingInfo) { + this.rankingInfo = rankingInfo; + return this; + } + + /** + * Get rankingInfo + * + * @return rankingInfo + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public RankingInfo getRankingInfo() { + return rankingInfo; + } + + public void setRankingInfo(RankingInfo rankingInfo) { + this.rankingInfo = rankingInfo; + } + + public Record distinctSeqID(Integer distinctSeqID) { + this.distinctSeqID = distinctSeqID; + return this; + } + + /** + * Get distinctSeqID + * + * @return distinctSeqID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public Integer getDistinctSeqID() { + return distinctSeqID; + } + + public void setDistinctSeqID(Integer distinctSeqID) { + this.distinctSeqID = distinctSeqID; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Record record = (Record) o; + return ( + Objects.equals(this.objectID, record.objectID) && + Objects.equals(this.highlightResult, record.highlightResult) && + Objects.equals(this.snippetResult, record.snippetResult) && + Objects.equals(this.rankingInfo, record.rankingInfo) && + Objects.equals(this.distinctSeqID, record.distinctSeqID) && + super.equals(o) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + objectID, + highlightResult, + snippetResult, + rankingInfo, + distinctSeqID, + super.hashCode() + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Record {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" objectID: ").append(toIndentedString(objectID)).append("\n"); + sb + .append(" highlightResult: ") + .append(toIndentedString(highlightResult)) + .append("\n"); + sb + .append(" snippetResult: ") + .append(toIndentedString(snippetResult)) + .append("\n"); + sb + .append(" rankingInfo: ") + .append(toIndentedString(rankingInfo)) + .append("\n"); + sb + .append(" distinctSeqID: ") + .append(toIndentedString(distinctSeqID)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveObjectResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveObjectResponse.java new file mode 100644 index 00000000000..176038ae909 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveObjectResponse.java @@ -0,0 +1,129 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.Objects; + +/** SaveObjectResponse */ +public class SaveObjectResponse { + + public static final String SERIALIZED_NAME_CREATED_AT = "createdAt"; + + @SerializedName(SERIALIZED_NAME_CREATED_AT) + private String createdAt; + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_OBJECT_I_D = "objectID"; + + @SerializedName(SERIALIZED_NAME_OBJECT_I_D) + private String objectID; + + public SaveObjectResponse createdAt(String createdAt) { + this.createdAt = createdAt; + return this; + } + + /** + * Get createdAt + * + * @return createdAt + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public String getCreatedAt() { + return createdAt; + } + + public void setCreatedAt(String createdAt) { + this.createdAt = createdAt; + } + + public SaveObjectResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "taskID of the indexing task to wait for.") + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public SaveObjectResponse objectID(String objectID) { + this.objectID = objectID; + return this; + } + + /** + * Unique identifier of the object. + * + * @return objectID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Unique identifier of the object.") + public String getObjectID() { + return objectID; + } + + public void setObjectID(String objectID) { + this.objectID = objectID; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SaveObjectResponse saveObjectResponse = (SaveObjectResponse) o; + return ( + Objects.equals(this.createdAt, saveObjectResponse.createdAt) && + Objects.equals(this.taskID, saveObjectResponse.taskID) && + Objects.equals(this.objectID, saveObjectResponse.objectID) + ); + } + + @Override + public int hashCode() { + return Objects.hash(createdAt, taskID, objectID); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SaveObjectResponse {\n"); + sb + .append(" createdAt: ") + .append(toIndentedString(createdAt)) + .append("\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb.append(" objectID: ").append(toIndentedString(objectID)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymResponse.java new file mode 100644 index 00000000000..47a5c4d96e9 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymResponse.java @@ -0,0 +1,136 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** SaveSynonymResponse */ +public class SaveSynonymResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public static final String SERIALIZED_NAME_ID = "id"; + + @SerializedName(SERIALIZED_NAME_ID) + private String id; + + public SaveSynonymResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "taskID of the indexing task to wait for." + ) + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public SaveSynonymResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Date of last update (ISO-8601 format)." + ) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + public SaveSynonymResponse id(String id) { + this.id = id; + return this; + } + + /** + * objectID of the inserted object. + * + * @return id + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "objectID of the inserted object.") + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SaveSynonymResponse saveSynonymResponse = (SaveSynonymResponse) o; + return ( + Objects.equals(this.taskID, saveSynonymResponse.taskID) && + Objects.equals(this.updatedAt, saveSynonymResponse.updatedAt) && + Objects.equals(this.id, saveSynonymResponse.id) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, updatedAt, id); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SaveSynonymResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .append("\n"); + sb.append(" id: ").append(toIndentedString(id)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymsResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymsResponse.java new file mode 100644 index 00000000000..f6b8e6da208 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SaveSynonymsResponse.java @@ -0,0 +1,109 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** SaveSynonymsResponse */ +public class SaveSynonymsResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public SaveSynonymsResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "taskID of the indexing task to wait for." + ) + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public SaveSynonymsResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Date of last update (ISO-8601 format)." + ) + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SaveSynonymsResponse saveSynonymsResponse = (SaveSynonymsResponse) o; + return ( + Objects.equals(this.taskID, saveSynonymsResponse.taskID) && + Objects.equals(this.updatedAt, saveSynonymsResponse.updatedAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SaveSynonymsResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchHits.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchHits.java new file mode 100644 index 00000000000..0901da6c69c --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchHits.java @@ -0,0 +1,80 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** SearchHits */ +public class SearchHits { + + public static final String SERIALIZED_NAME_HITS = "hits"; + + @SerializedName(SERIALIZED_NAME_HITS) + private List hits = null; + + public SearchHits hits(List hits) { + this.hits = hits; + return this; + } + + public SearchHits addHitsItem(Record hitsItem) { + if (this.hits == null) { + this.hits = new ArrayList<>(); + } + this.hits.add(hitsItem); + return this; + } + + /** + * Get hits + * + * @return hits + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public List getHits() { + return hits; + } + + public void setHits(List hits) { + this.hits = hits; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchHits searchHits = (SearchHits) o; + return Objects.equals(this.hits, searchHits.hits); + } + + @Override + public int hashCode() { + return Objects.hash(hits); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchHits {\n"); + sb.append(" hits: ").append(toIndentedString(hits)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java new file mode 100644 index 00000000000..81b9a491f54 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchParams.java @@ -0,0 +1,3315 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; +import org.openapitools.jackson.nullable.JsonNullable; + +/** SearchParams */ +public class SearchParams { + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + public static final String SERIALIZED_NAME_SIMILAR_QUERY = "similarQuery"; + + @SerializedName(SERIALIZED_NAME_SIMILAR_QUERY) + private String similarQuery = ""; + + public static final String SERIALIZED_NAME_FILTERS = "filters"; + + @SerializedName(SERIALIZED_NAME_FILTERS) + private String filters = ""; + + public static final String SERIALIZED_NAME_FACET_FILTERS = "facetFilters"; + + @SerializedName(SERIALIZED_NAME_FACET_FILTERS) + private List facetFilters = null; + + public static final String SERIALIZED_NAME_OPTIONAL_FILTERS = + "optionalFilters"; + + @SerializedName(SERIALIZED_NAME_OPTIONAL_FILTERS) + private List optionalFilters = null; + + public static final String SERIALIZED_NAME_NUMERIC_FILTERS = "numericFilters"; + + @SerializedName(SERIALIZED_NAME_NUMERIC_FILTERS) + private List numericFilters = null; + + public static final String SERIALIZED_NAME_TAG_FILTERS = "tagFilters"; + + @SerializedName(SERIALIZED_NAME_TAG_FILTERS) + private List tagFilters = null; + + public static final String SERIALIZED_NAME_SUM_OR_FILTERS_SCORES = + "sumOrFiltersScores"; + + @SerializedName(SERIALIZED_NAME_SUM_OR_FILTERS_SCORES) + private Boolean sumOrFiltersScores = false; + + public static final String SERIALIZED_NAME_FACETS = "facets"; + + @SerializedName(SERIALIZED_NAME_FACETS) + private List facets = null; + + public static final String SERIALIZED_NAME_MAX_VALUES_PER_FACET = + "maxValuesPerFacet"; + + @SerializedName(SERIALIZED_NAME_MAX_VALUES_PER_FACET) + private Integer maxValuesPerFacet = 100; + + public static final String SERIALIZED_NAME_FACETING_AFTER_DISTINCT = + "facetingAfterDistinct"; + + @SerializedName(SERIALIZED_NAME_FACETING_AFTER_DISTINCT) + private Boolean facetingAfterDistinct = false; + + public static final String SERIALIZED_NAME_SORT_FACET_VALUES_BY = + "sortFacetValuesBy"; + + @SerializedName(SERIALIZED_NAME_SORT_FACET_VALUES_BY) + private String sortFacetValuesBy = "count"; + + public static final String SERIALIZED_NAME_PAGE = "page"; + + @SerializedName(SERIALIZED_NAME_PAGE) + private Integer page = 0; + + public static final String SERIALIZED_NAME_OFFSET = "offset"; + + @SerializedName(SERIALIZED_NAME_OFFSET) + private Integer offset; + + public static final String SERIALIZED_NAME_LENGTH = "length"; + + @SerializedName(SERIALIZED_NAME_LENGTH) + private Integer length; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG = "aroundLatLng"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG) + private String aroundLatLng = ""; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG_VIA_I_P = + "aroundLatLngViaIP"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG_VIA_I_P) + private Boolean aroundLatLngViaIP = false; + + public static final String SERIALIZED_NAME_AROUND_RADIUS = "aroundRadius"; + + @SerializedName(SERIALIZED_NAME_AROUND_RADIUS) + private OneOfintegerstring aroundRadius; + + public static final String SERIALIZED_NAME_AROUND_PRECISION = + "aroundPrecision"; + + @SerializedName(SERIALIZED_NAME_AROUND_PRECISION) + private Integer aroundPrecision = 10; + + public static final String SERIALIZED_NAME_MINIMUM_AROUND_RADIUS = + "minimumAroundRadius"; + + @SerializedName(SERIALIZED_NAME_MINIMUM_AROUND_RADIUS) + private Integer minimumAroundRadius; + + public static final String SERIALIZED_NAME_INSIDE_BOUNDING_BOX = + "insideBoundingBox"; + + @SerializedName(SERIALIZED_NAME_INSIDE_BOUNDING_BOX) + private List insideBoundingBox = null; + + public static final String SERIALIZED_NAME_INSIDE_POLYGON = "insidePolygon"; + + @SerializedName(SERIALIZED_NAME_INSIDE_POLYGON) + private List insidePolygon = null; + + public static final String SERIALIZED_NAME_NATURAL_LANGUAGES = + "naturalLanguages"; + + @SerializedName(SERIALIZED_NAME_NATURAL_LANGUAGES) + private List naturalLanguages = null; + + public static final String SERIALIZED_NAME_RULE_CONTEXTS = "ruleContexts"; + + @SerializedName(SERIALIZED_NAME_RULE_CONTEXTS) + private List ruleContexts = null; + + public static final String SERIALIZED_NAME_PERSONALIZATION_IMPACT = + "personalizationImpact"; + + @SerializedName(SERIALIZED_NAME_PERSONALIZATION_IMPACT) + private Integer personalizationImpact = 100; + + public static final String SERIALIZED_NAME_USER_TOKEN = "userToken"; + + @SerializedName(SERIALIZED_NAME_USER_TOKEN) + private String userToken; + + public static final String SERIALIZED_NAME_GET_RANKING_INFO = + "getRankingInfo"; + + @SerializedName(SERIALIZED_NAME_GET_RANKING_INFO) + private Boolean getRankingInfo = false; + + public static final String SERIALIZED_NAME_CLICK_ANALYTICS = "clickAnalytics"; + + @SerializedName(SERIALIZED_NAME_CLICK_ANALYTICS) + private Boolean clickAnalytics = false; + + public static final String SERIALIZED_NAME_ANALYTICS = "analytics"; + + @SerializedName(SERIALIZED_NAME_ANALYTICS) + private Boolean analytics = true; + + public static final String SERIALIZED_NAME_ANALYTICS_TAGS = "analyticsTags"; + + @SerializedName(SERIALIZED_NAME_ANALYTICS_TAGS) + private List analyticsTags = null; + + public static final String SERIALIZED_NAME_PERCENTILE_COMPUTATION = + "percentileComputation"; + + @SerializedName(SERIALIZED_NAME_PERCENTILE_COMPUTATION) + private Boolean percentileComputation = true; + + public static final String SERIALIZED_NAME_ENABLE_A_B_TEST = "enableABTest"; + + @SerializedName(SERIALIZED_NAME_ENABLE_A_B_TEST) + private Boolean enableABTest = true; + + public static final String SERIALIZED_NAME_ENABLE_RE_RANKING = + "enableReRanking"; + + @SerializedName(SERIALIZED_NAME_ENABLE_RE_RANKING) + private Boolean enableReRanking = true; + + public static final String SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES = + "searchableAttributes"; + + @SerializedName(SERIALIZED_NAME_SEARCHABLE_ATTRIBUTES) + private List searchableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING = + "attributesForFaceting"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_FOR_FACETING) + private List attributesForFaceting = null; + + public static final String SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES = + "unretrievableAttributes"; + + @SerializedName(SERIALIZED_NAME_UNRETRIEVABLE_ATTRIBUTES) + private List unretrievableAttributes = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE = + "attributesToRetrieve"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_RETRIEVE) + private List attributesToRetrieve = null; + + public static final String SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES = + "restrictSearchableAttributes"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_SEARCHABLE_ATTRIBUTES) + private List restrictSearchableAttributes = null; + + public static final String SERIALIZED_NAME_RANKING = "ranking"; + + @SerializedName(SERIALIZED_NAME_RANKING) + private List ranking = null; + + public static final String SERIALIZED_NAME_CUSTOM_RANKING = "customRanking"; + + @SerializedName(SERIALIZED_NAME_CUSTOM_RANKING) + private List customRanking = null; + + public static final String SERIALIZED_NAME_RELEVANCY_STRICTNESS = + "relevancyStrictness"; + + @SerializedName(SERIALIZED_NAME_RELEVANCY_STRICTNESS) + private Integer relevancyStrictness = 100; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT = + "attributesToHighlight"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_HIGHLIGHT) + private List attributesToHighlight = null; + + public static final String SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET = + "attributesToSnippet"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTES_TO_SNIPPET) + private List attributesToSnippet = null; + + public static final String SERIALIZED_NAME_HIGHLIGHT_PRE_TAG = + "highlightPreTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_PRE_TAG) + private String highlightPreTag = ""; + + public static final String SERIALIZED_NAME_HIGHLIGHT_POST_TAG = + "highlightPostTag"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_POST_TAG) + private String highlightPostTag = ""; + + public static final String SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT = + "snippetEllipsisText"; + + @SerializedName(SERIALIZED_NAME_SNIPPET_ELLIPSIS_TEXT) + private String snippetEllipsisText = "…"; + + public static final String SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS = + "restrictHighlightAndSnippetArrays"; + + @SerializedName(SERIALIZED_NAME_RESTRICT_HIGHLIGHT_AND_SNIPPET_ARRAYS) + private Boolean restrictHighlightAndSnippetArrays = false; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO = + "minWordSizefor1Typo"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR1_TYPO) + private Integer minWordSizefor1Typo = 4; + + public static final String SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS = + "minWordSizefor2Typos"; + + @SerializedName(SERIALIZED_NAME_MIN_WORD_SIZEFOR2_TYPOS) + private Integer minWordSizefor2Typos = 8; + + /** Controls whether typo tolerance is enabled and how it is applied. */ + @JsonAdapter(TypoToleranceEnum.Adapter.class) + public enum TypoToleranceEnum { + TRUE("true"), + + FALSE("false"), + + MIN("min"), + + STRICT("strict"); + + private String value; + + TypoToleranceEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypoToleranceEnum fromValue(String value) { + for (TypoToleranceEnum b : TypoToleranceEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final TypoToleranceEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypoToleranceEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return TypoToleranceEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPO_TOLERANCE = "typoTolerance"; + + @SerializedName(SERIALIZED_NAME_TYPO_TOLERANCE) + private TypoToleranceEnum typoTolerance = TypoToleranceEnum.TRUE; + + public static final String SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS = + "allowTyposOnNumericTokens"; + + @SerializedName(SERIALIZED_NAME_ALLOW_TYPOS_ON_NUMERIC_TOKENS) + private Boolean allowTyposOnNumericTokens = true; + + public static final String SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES = + "disableTypoToleranceOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_TYPO_TOLERANCE_ON_ATTRIBUTES) + private List disableTypoToleranceOnAttributes = null; + + public static final String SERIALIZED_NAME_SEPARATORS_TO_INDEX = + "separatorsToIndex"; + + @SerializedName(SERIALIZED_NAME_SEPARATORS_TO_INDEX) + private String separatorsToIndex = ""; + + public static final String SERIALIZED_NAME_IGNORE_PLURALS = "ignorePlurals"; + + @SerializedName(SERIALIZED_NAME_IGNORE_PLURALS) + private String ignorePlurals = "false"; + + public static final String SERIALIZED_NAME_REMOVE_STOP_WORDS = + "removeStopWords"; + + @SerializedName(SERIALIZED_NAME_REMOVE_STOP_WORDS) + private String removeStopWords = "false"; + + public static final String SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS = + "keepDiacriticsOnCharacters"; + + @SerializedName(SERIALIZED_NAME_KEEP_DIACRITICS_ON_CHARACTERS) + private String keepDiacriticsOnCharacters = ""; + + public static final String SERIALIZED_NAME_QUERY_LANGUAGES = "queryLanguages"; + + @SerializedName(SERIALIZED_NAME_QUERY_LANGUAGES) + private List queryLanguages = null; + + public static final String SERIALIZED_NAME_DECOMPOUND_QUERY = + "decompoundQuery"; + + @SerializedName(SERIALIZED_NAME_DECOMPOUND_QUERY) + private Boolean decompoundQuery = true; + + public static final String SERIALIZED_NAME_ENABLE_RULES = "enableRules"; + + @SerializedName(SERIALIZED_NAME_ENABLE_RULES) + private Boolean enableRules = true; + + public static final String SERIALIZED_NAME_ENABLE_PERSONALIZATION = + "enablePersonalization"; + + @SerializedName(SERIALIZED_NAME_ENABLE_PERSONALIZATION) + private Boolean enablePersonalization = false; + + /** Controls if and how query words are interpreted as prefixes. */ + @JsonAdapter(QueryTypeEnum.Adapter.class) + public enum QueryTypeEnum { + PREFIXLAST("prefixLast"), + + PREFIXALL("prefixAll"), + + PREFIXNONE("prefixNone"); + + private String value; + + QueryTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static QueryTypeEnum fromValue(String value) { + for (QueryTypeEnum b : QueryTypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final QueryTypeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public QueryTypeEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return QueryTypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_QUERY_TYPE = "queryType"; + + @SerializedName(SERIALIZED_NAME_QUERY_TYPE) + private QueryTypeEnum queryType = QueryTypeEnum.PREFIXLAST; + + /** Selects a strategy to remove words from the query when it doesn’t match any hits. */ + @JsonAdapter(RemoveWordsIfNoResultsEnum.Adapter.class) + public enum RemoveWordsIfNoResultsEnum { + NONE("none"), + + LASTWORDS("lastWords"), + + FIRSTWORDS("firstWords"), + + ALLOPTIONAL("allOptional"); + + private String value; + + RemoveWordsIfNoResultsEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static RemoveWordsIfNoResultsEnum fromValue(String value) { + for (RemoveWordsIfNoResultsEnum b : RemoveWordsIfNoResultsEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final RemoveWordsIfNoResultsEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public RemoveWordsIfNoResultsEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return RemoveWordsIfNoResultsEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS = + "removeWordsIfNoResults"; + + @SerializedName(SERIALIZED_NAME_REMOVE_WORDS_IF_NO_RESULTS) + private RemoveWordsIfNoResultsEnum removeWordsIfNoResults = + RemoveWordsIfNoResultsEnum.NONE; + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX = "advancedSyntax"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX) + private Boolean advancedSyntax = false; + + public static final String SERIALIZED_NAME_OPTIONAL_WORDS = "optionalWords"; + + @SerializedName(SERIALIZED_NAME_OPTIONAL_WORDS) + private List optionalWords = null; + + public static final String SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES = + "disableExactOnAttributes"; + + @SerializedName(SERIALIZED_NAME_DISABLE_EXACT_ON_ATTRIBUTES) + private List disableExactOnAttributes = null; + + /** Controls how the exact ranking criterion is computed when the query contains only one word. */ + @JsonAdapter(ExactOnSingleWordQueryEnum.Adapter.class) + public enum ExactOnSingleWordQueryEnum { + ATTRIBUTE("attribute"), + + NONE("none"), + + WORD("word"); + + private String value; + + ExactOnSingleWordQueryEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static ExactOnSingleWordQueryEnum fromValue(String value) { + for (ExactOnSingleWordQueryEnum b : ExactOnSingleWordQueryEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final ExactOnSingleWordQueryEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public ExactOnSingleWordQueryEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return ExactOnSingleWordQueryEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY = + "exactOnSingleWordQuery"; + + @SerializedName(SERIALIZED_NAME_EXACT_ON_SINGLE_WORD_QUERY) + private ExactOnSingleWordQueryEnum exactOnSingleWordQuery = + ExactOnSingleWordQueryEnum.ATTRIBUTE; + + /** Gets or Sets alternativesAsExact */ + @JsonAdapter(AlternativesAsExactEnum.Adapter.class) + public enum AlternativesAsExactEnum { + IGNOREPLURALS("ignorePlurals"), + + SINGLEWORDSYNONYM("singleWordSynonym"), + + MULTIWORDSSYNONYM("multiWordsSynonym"); + + private String value; + + AlternativesAsExactEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AlternativesAsExactEnum fromValue(String value) { + for (AlternativesAsExactEnum b : AlternativesAsExactEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AlternativesAsExactEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AlternativesAsExactEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AlternativesAsExactEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ALTERNATIVES_AS_EXACT = + "alternativesAsExact"; + + @SerializedName(SERIALIZED_NAME_ALTERNATIVES_AS_EXACT) + private List alternativesAsExact = null; + + /** Gets or Sets advancedSyntaxFeatures */ + @JsonAdapter(AdvancedSyntaxFeaturesEnum.Adapter.class) + public enum AdvancedSyntaxFeaturesEnum { + EXACTPHRASE("exactPhrase"), + + EXCLUDEWORDS("excludeWords"); + + private String value; + + AdvancedSyntaxFeaturesEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static AdvancedSyntaxFeaturesEnum fromValue(String value) { + for (AdvancedSyntaxFeaturesEnum b : AdvancedSyntaxFeaturesEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter + extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final AdvancedSyntaxFeaturesEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public AdvancedSyntaxFeaturesEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return AdvancedSyntaxFeaturesEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES = + "advancedSyntaxFeatures"; + + @SerializedName(SERIALIZED_NAME_ADVANCED_SYNTAX_FEATURES) + private List advancedSyntaxFeatures = null; + + public static final String SERIALIZED_NAME_DISTINCT = "distinct"; + + @SerializedName(SERIALIZED_NAME_DISTINCT) + private Integer distinct = 0; + + public static final String SERIALIZED_NAME_SYNONYMS = "synonyms"; + + @SerializedName(SERIALIZED_NAME_SYNONYMS) + private Boolean synonyms = true; + + public static final String SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT = + "replaceSynonymsInHighlight"; + + @SerializedName(SERIALIZED_NAME_REPLACE_SYNONYMS_IN_HIGHLIGHT) + private Boolean replaceSynonymsInHighlight = false; + + public static final String SERIALIZED_NAME_MIN_PROXIMITY = "minProximity"; + + @SerializedName(SERIALIZED_NAME_MIN_PROXIMITY) + private Integer minProximity = 1; + + public static final String SERIALIZED_NAME_RESPONSE_FIELDS = "responseFields"; + + @SerializedName(SERIALIZED_NAME_RESPONSE_FIELDS) + private List responseFields = null; + + public static final String SERIALIZED_NAME_MAX_FACET_HITS = "maxFacetHits"; + + @SerializedName(SERIALIZED_NAME_MAX_FACET_HITS) + private Integer maxFacetHits = 10; + + public static final String SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY = + "attributeCriteriaComputedByMinProximity"; + + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_CRITERIA_COMPUTED_BY_MIN_PROXIMITY) + private Boolean attributeCriteriaComputedByMinProximity = false; + + public static final String SERIALIZED_NAME_RENDERING_CONTENT = + "renderingContent"; + + @SerializedName(SERIALIZED_NAME_RENDERING_CONTENT) + private Object renderingContent = new Object(); + + public SearchParams query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public SearchParams similarQuery(String similarQuery) { + this.similarQuery = similarQuery; + return this; + } + + /** + * Overrides the query parameter and performs a more generic search that can be used to find + * \"similar\" results. + * + * @return similarQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Overrides the query parameter and performs a more generic search that can be used to" + + " find \"similar\" results." + ) + public String getSimilarQuery() { + return similarQuery; + } + + public void setSimilarQuery(String similarQuery) { + this.similarQuery = similarQuery; + } + + public SearchParams filters(String filters) { + this.filters = filters; + return this; + } + + /** + * Filter the query with numeric, facet and/or tag filters. + * + * @return filters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Filter the query with numeric, facet and/or tag filters." + ) + public String getFilters() { + return filters; + } + + public void setFilters(String filters) { + this.filters = filters; + } + + public SearchParams facetFilters(List facetFilters) { + this.facetFilters = facetFilters; + return this; + } + + public SearchParams addFacetFiltersItem(String facetFiltersItem) { + if (this.facetFilters == null) { + this.facetFilters = new ArrayList<>(); + } + this.facetFilters.add(facetFiltersItem); + return this; + } + + /** + * Filter hits by facet value. + * + * @return facetFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter hits by facet value.") + public List getFacetFilters() { + return facetFilters; + } + + public void setFacetFilters(List facetFilters) { + this.facetFilters = facetFilters; + } + + public SearchParams optionalFilters(List optionalFilters) { + this.optionalFilters = optionalFilters; + return this; + } + + public SearchParams addOptionalFiltersItem(String optionalFiltersItem) { + if (this.optionalFilters == null) { + this.optionalFilters = new ArrayList<>(); + } + this.optionalFilters.add(optionalFiltersItem); + return this; + } + + /** + * Create filters for ranking purposes, where records that match the filter are ranked higher, or + * lower in the case of a negative optional filter. + * + * @return optionalFilters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Create filters for ranking purposes, where records that match the filter are ranked" + + " higher, or lower in the case of a negative optional filter." + ) + public List getOptionalFilters() { + return optionalFilters; + } + + public void setOptionalFilters(List optionalFilters) { + this.optionalFilters = optionalFilters; + } + + public SearchParams numericFilters(List numericFilters) { + this.numericFilters = numericFilters; + return this; + } + + public SearchParams addNumericFiltersItem(String numericFiltersItem) { + if (this.numericFilters == null) { + this.numericFilters = new ArrayList<>(); + } + this.numericFilters.add(numericFiltersItem); + return this; + } + + /** + * Filter on numeric attributes. + * + * @return numericFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter on numeric attributes.") + public List getNumericFilters() { + return numericFilters; + } + + public void setNumericFilters(List numericFilters) { + this.numericFilters = numericFilters; + } + + public SearchParams tagFilters(List tagFilters) { + this.tagFilters = tagFilters; + return this; + } + + public SearchParams addTagFiltersItem(String tagFiltersItem) { + if (this.tagFilters == null) { + this.tagFilters = new ArrayList<>(); + } + this.tagFilters.add(tagFiltersItem); + return this; + } + + /** + * Filter hits by tags. + * + * @return tagFilters + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Filter hits by tags.") + public List getTagFilters() { + return tagFilters; + } + + public void setTagFilters(List tagFilters) { + this.tagFilters = tagFilters; + } + + public SearchParams sumOrFiltersScores(Boolean sumOrFiltersScores) { + this.sumOrFiltersScores = sumOrFiltersScores; + return this; + } + + /** + * Determines how to calculate the total score for filtering. + * + * @return sumOrFiltersScores + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Determines how to calculate the total score for filtering." + ) + public Boolean getSumOrFiltersScores() { + return sumOrFiltersScores; + } + + public void setSumOrFiltersScores(Boolean sumOrFiltersScores) { + this.sumOrFiltersScores = sumOrFiltersScores; + } + + public SearchParams facets(List facets) { + this.facets = facets; + return this; + } + + public SearchParams addFacetsItem(String facetsItem) { + if (this.facets == null) { + this.facets = new ArrayList<>(); + } + this.facets.add(facetsItem); + return this; + } + + /** + * Retrieve facets and their facet values. + * + * @return facets + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Retrieve facets and their facet values.") + public List getFacets() { + return facets; + } + + public void setFacets(List facets) { + this.facets = facets; + } + + public SearchParams maxValuesPerFacet(Integer maxValuesPerFacet) { + this.maxValuesPerFacet = maxValuesPerFacet; + return this; + } + + /** + * Maximum number of facet values to return for each facet during a regular search. + * + * @return maxValuesPerFacet + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet values to return for each facet during a regular search." + ) + public Integer getMaxValuesPerFacet() { + return maxValuesPerFacet; + } + + public void setMaxValuesPerFacet(Integer maxValuesPerFacet) { + this.maxValuesPerFacet = maxValuesPerFacet; + } + + public SearchParams facetingAfterDistinct(Boolean facetingAfterDistinct) { + this.facetingAfterDistinct = facetingAfterDistinct; + return this; + } + + /** + * Force faceting to be applied after de-duplication (via the Distinct setting). + * + * @return facetingAfterDistinct + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Force faceting to be applied after de-duplication (via the Distinct setting)." + ) + public Boolean getFacetingAfterDistinct() { + return facetingAfterDistinct; + } + + public void setFacetingAfterDistinct(Boolean facetingAfterDistinct) { + this.facetingAfterDistinct = facetingAfterDistinct; + } + + public SearchParams sortFacetValuesBy(String sortFacetValuesBy) { + this.sortFacetValuesBy = sortFacetValuesBy; + return this; + } + + /** + * Controls how facet values are fetched. + * + * @return sortFacetValuesBy + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Controls how facet values are fetched.") + public String getSortFacetValuesBy() { + return sortFacetValuesBy; + } + + public void setSortFacetValuesBy(String sortFacetValuesBy) { + this.sortFacetValuesBy = sortFacetValuesBy; + } + + public SearchParams page(Integer page) { + this.page = page; + return this; + } + + /** + * Specify the page to retrieve. + * + * @return page + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specify the page to retrieve.") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public SearchParams offset(Integer offset) { + this.offset = offset; + return this; + } + + /** + * Specify the offset of the first hit to return. + * + * @return offset + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specify the offset of the first hit to return.") + public Integer getOffset() { + return offset; + } + + public void setOffset(Integer offset) { + this.offset = offset; + } + + public SearchParams length(Integer length) { + this.length = length; + return this; + } + + /** + * Set the number of hits to retrieve (used only with offset). minimum: 1 maximum: 1000 + * + * @return length + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Set the number of hits to retrieve (used only with offset)." + ) + public Integer getLength() { + return length; + } + + public void setLength(Integer length) { + this.length = length; + } + + public SearchParams aroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + return this; + } + + /** + * Search for entries around a central geolocation, enabling a geo search within a circular area. + * + * @return aroundLatLng + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search for entries around a central geolocation, enabling a geo search within a circular" + + " area." + ) + public String getAroundLatLng() { + return aroundLatLng; + } + + public void setAroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + } + + public SearchParams aroundLatLngViaIP(Boolean aroundLatLngViaIP) { + this.aroundLatLngViaIP = aroundLatLngViaIP; + return this; + } + + /** + * Search for entries around a given location automatically computed from the requester’s IP + * address. + * + * @return aroundLatLngViaIP + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search for entries around a given location automatically computed from the requester’s" + + " IP address." + ) + public Boolean getAroundLatLngViaIP() { + return aroundLatLngViaIP; + } + + public void setAroundLatLngViaIP(Boolean aroundLatLngViaIP) { + this.aroundLatLngViaIP = aroundLatLngViaIP; + } + + public SearchParams aroundRadius(OneOfintegerstring aroundRadius) { + this.aroundRadius = aroundRadius; + return this; + } + + /** + * Define the maximum radius for a geo search (in meters). + * + * @return aroundRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Define the maximum radius for a geo search (in meters)." + ) + public OneOfintegerstring getAroundRadius() { + return aroundRadius; + } + + public void setAroundRadius(OneOfintegerstring aroundRadius) { + this.aroundRadius = aroundRadius; + } + + public SearchParams aroundPrecision(Integer aroundPrecision) { + this.aroundPrecision = aroundPrecision; + return this; + } + + /** + * Precision of geo search (in meters), to add grouping by geo location to the ranking formula. + * + * @return aroundPrecision + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Precision of geo search (in meters), to add grouping by geo location to the ranking" + + " formula." + ) + public Integer getAroundPrecision() { + return aroundPrecision; + } + + public void setAroundPrecision(Integer aroundPrecision) { + this.aroundPrecision = aroundPrecision; + } + + public SearchParams minimumAroundRadius(Integer minimumAroundRadius) { + this.minimumAroundRadius = minimumAroundRadius; + return this; + } + + /** + * Minimum radius (in meters) used for a geo search when aroundRadius is not set. minimum: 1 + * + * @return minimumAroundRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum radius (in meters) used for a geo search when aroundRadius is not set." + ) + public Integer getMinimumAroundRadius() { + return minimumAroundRadius; + } + + public void setMinimumAroundRadius(Integer minimumAroundRadius) { + this.minimumAroundRadius = minimumAroundRadius; + } + + public SearchParams insideBoundingBox(List insideBoundingBox) { + this.insideBoundingBox = insideBoundingBox; + return this; + } + + public SearchParams addInsideBoundingBoxItem( + BigDecimal insideBoundingBoxItem + ) { + if (this.insideBoundingBox == null) { + this.insideBoundingBox = new ArrayList<>(); + } + this.insideBoundingBox.add(insideBoundingBoxItem); + return this; + } + + /** + * Search inside a rectangular area (in geo coordinates). + * + * @return insideBoundingBox + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Search inside a rectangular area (in geo coordinates)." + ) + public List getInsideBoundingBox() { + return insideBoundingBox; + } + + public void setInsideBoundingBox(List insideBoundingBox) { + this.insideBoundingBox = insideBoundingBox; + } + + public SearchParams insidePolygon(List insidePolygon) { + this.insidePolygon = insidePolygon; + return this; + } + + public SearchParams addInsidePolygonItem(BigDecimal insidePolygonItem) { + if (this.insidePolygon == null) { + this.insidePolygon = new ArrayList<>(); + } + this.insidePolygon.add(insidePolygonItem); + return this; + } + + /** + * Search inside a polygon (in geo coordinates). + * + * @return insidePolygon + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Search inside a polygon (in geo coordinates).") + public List getInsidePolygon() { + return insidePolygon; + } + + public void setInsidePolygon(List insidePolygon) { + this.insidePolygon = insidePolygon; + } + + public SearchParams naturalLanguages(List naturalLanguages) { + this.naturalLanguages = naturalLanguages; + return this; + } + + public SearchParams addNaturalLanguagesItem(String naturalLanguagesItem) { + if (this.naturalLanguages == null) { + this.naturalLanguages = new ArrayList<>(); + } + this.naturalLanguages.add(naturalLanguagesItem); + return this; + } + + /** + * This parameter changes the default values of certain parameters and settings that work best for + * a natural language query, such as ignorePlurals, removeStopWords, removeWordsIfNoResults, + * analyticsTags and ruleContexts. These parameters and settings work well together when the query + * is formatted in natural language instead of keywords, for example when your user performs a + * voice search. + * + * @return naturalLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "This parameter changes the default values of certain parameters and settings that work" + + " best for a natural language query, such as ignorePlurals, removeStopWords," + + " removeWordsIfNoResults, analyticsTags and ruleContexts. These parameters and" + + " settings work well together when the query is formatted in natural language" + + " instead of keywords, for example when your user performs a voice search." + ) + public List getNaturalLanguages() { + return naturalLanguages; + } + + public void setNaturalLanguages(List naturalLanguages) { + this.naturalLanguages = naturalLanguages; + } + + public SearchParams ruleContexts(List ruleContexts) { + this.ruleContexts = ruleContexts; + return this; + } + + public SearchParams addRuleContextsItem(String ruleContextsItem) { + if (this.ruleContexts == null) { + this.ruleContexts = new ArrayList<>(); + } + this.ruleContexts.add(ruleContextsItem); + return this; + } + + /** + * Enables contextual rules. + * + * @return ruleContexts + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables contextual rules.") + public List getRuleContexts() { + return ruleContexts; + } + + public void setRuleContexts(List ruleContexts) { + this.ruleContexts = ruleContexts; + } + + public SearchParams personalizationImpact(Integer personalizationImpact) { + this.personalizationImpact = personalizationImpact; + return this; + } + + /** + * Define the impact of the Personalization feature. + * + * @return personalizationImpact + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Define the impact of the Personalization feature.") + public Integer getPersonalizationImpact() { + return personalizationImpact; + } + + public void setPersonalizationImpact(Integer personalizationImpact) { + this.personalizationImpact = personalizationImpact; + } + + public SearchParams userToken(String userToken) { + this.userToken = userToken; + return this; + } + + /** + * Associates a certain user token with the current search. + * + * @return userToken + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Associates a certain user token with the current search." + ) + public String getUserToken() { + return userToken; + } + + public void setUserToken(String userToken) { + this.userToken = userToken; + } + + public SearchParams getRankingInfo(Boolean getRankingInfo) { + this.getRankingInfo = getRankingInfo; + return this; + } + + /** + * Retrieve detailed ranking information. + * + * @return getRankingInfo + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Retrieve detailed ranking information.") + public Boolean getGetRankingInfo() { + return getRankingInfo; + } + + public void setGetRankingInfo(Boolean getRankingInfo) { + this.getRankingInfo = getRankingInfo; + } + + public SearchParams clickAnalytics(Boolean clickAnalytics) { + this.clickAnalytics = clickAnalytics; + return this; + } + + /** + * Enable the Click Analytics feature. + * + * @return clickAnalytics + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enable the Click Analytics feature.") + public Boolean getClickAnalytics() { + return clickAnalytics; + } + + public void setClickAnalytics(Boolean clickAnalytics) { + this.clickAnalytics = clickAnalytics; + } + + public SearchParams analytics(Boolean analytics) { + this.analytics = analytics; + return this; + } + + /** + * Whether the current query will be taken into account in the Analytics. + * + * @return analytics + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the current query will be taken into account in the Analytics." + ) + public Boolean getAnalytics() { + return analytics; + } + + public void setAnalytics(Boolean analytics) { + this.analytics = analytics; + } + + public SearchParams analyticsTags(List analyticsTags) { + this.analyticsTags = analyticsTags; + return this; + } + + public SearchParams addAnalyticsTagsItem(String analyticsTagsItem) { + if (this.analyticsTags == null) { + this.analyticsTags = new ArrayList<>(); + } + this.analyticsTags.add(analyticsTagsItem); + return this; + } + + /** + * List of tags to apply to the query for analytics purposes. + * + * @return analyticsTags + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of tags to apply to the query for analytics purposes." + ) + public List getAnalyticsTags() { + return analyticsTags; + } + + public void setAnalyticsTags(List analyticsTags) { + this.analyticsTags = analyticsTags; + } + + public SearchParams percentileComputation(Boolean percentileComputation) { + this.percentileComputation = percentileComputation; + return this; + } + + /** + * Whether to include or exclude a query from the processing-time percentile computation. + * + * @return percentileComputation + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to include or exclude a query from the processing-time percentile computation." + ) + public Boolean getPercentileComputation() { + return percentileComputation; + } + + public void setPercentileComputation(Boolean percentileComputation) { + this.percentileComputation = percentileComputation; + } + + public SearchParams enableABTest(Boolean enableABTest) { + this.enableABTest = enableABTest; + return this; + } + + /** + * Whether this search should participate in running AB tests. + * + * @return enableABTest + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether this search should participate in running AB tests." + ) + public Boolean getEnableABTest() { + return enableABTest; + } + + public void setEnableABTest(Boolean enableABTest) { + this.enableABTest = enableABTest; + } + + public SearchParams enableReRanking(Boolean enableReRanking) { + this.enableReRanking = enableReRanking; + return this; + } + + /** + * Whether this search should use AI Re-Ranking. + * + * @return enableReRanking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether this search should use AI Re-Ranking.") + public Boolean getEnableReRanking() { + return enableReRanking; + } + + public void setEnableReRanking(Boolean enableReRanking) { + this.enableReRanking = enableReRanking; + } + + public SearchParams searchableAttributes(List searchableAttributes) { + this.searchableAttributes = searchableAttributes; + return this; + } + + public SearchParams addSearchableAttributesItem( + String searchableAttributesItem + ) { + if (this.searchableAttributes == null) { + this.searchableAttributes = new ArrayList<>(); + } + this.searchableAttributes.add(searchableAttributesItem); + return this; + } + + /** + * The complete list of attributes used for searching. + * + * @return searchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes used for searching." + ) + public List getSearchableAttributes() { + return searchableAttributes; + } + + public void setSearchableAttributes(List searchableAttributes) { + this.searchableAttributes = searchableAttributes; + } + + public SearchParams attributesForFaceting( + List attributesForFaceting + ) { + this.attributesForFaceting = attributesForFaceting; + return this; + } + + public SearchParams addAttributesForFacetingItem( + String attributesForFacetingItem + ) { + if (this.attributesForFaceting == null) { + this.attributesForFaceting = new ArrayList<>(); + } + this.attributesForFaceting.add(attributesForFacetingItem); + return this; + } + + /** + * The complete list of attributes that will be used for faceting. + * + * @return attributesForFaceting + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The complete list of attributes that will be used for faceting." + ) + public List getAttributesForFaceting() { + return attributesForFaceting; + } + + public void setAttributesForFaceting(List attributesForFaceting) { + this.attributesForFaceting = attributesForFaceting; + } + + public SearchParams unretrievableAttributes( + List unretrievableAttributes + ) { + this.unretrievableAttributes = unretrievableAttributes; + return this; + } + + public SearchParams addUnretrievableAttributesItem( + String unretrievableAttributesItem + ) { + if (this.unretrievableAttributes == null) { + this.unretrievableAttributes = new ArrayList<>(); + } + this.unretrievableAttributes.add(unretrievableAttributesItem); + return this; + } + + /** + * List of attributes that can’t be retrieved at query time. + * + * @return unretrievableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes that can’t be retrieved at query time." + ) + public List getUnretrievableAttributes() { + return unretrievableAttributes; + } + + public void setUnretrievableAttributes(List unretrievableAttributes) { + this.unretrievableAttributes = unretrievableAttributes; + } + + public SearchParams attributesToRetrieve(List attributesToRetrieve) { + this.attributesToRetrieve = attributesToRetrieve; + return this; + } + + public SearchParams addAttributesToRetrieveItem( + String attributesToRetrieveItem + ) { + if (this.attributesToRetrieve == null) { + this.attributesToRetrieve = new ArrayList<>(); + } + this.attributesToRetrieve.add(attributesToRetrieveItem); + return this; + } + + /** + * This parameter controls which attributes to retrieve and which not to retrieve. + * + * @return attributesToRetrieve + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "This parameter controls which attributes to retrieve and which not to retrieve." + ) + public List getAttributesToRetrieve() { + return attributesToRetrieve; + } + + public void setAttributesToRetrieve(List attributesToRetrieve) { + this.attributesToRetrieve = attributesToRetrieve; + } + + public SearchParams restrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + return this; + } + + public SearchParams addRestrictSearchableAttributesItem( + String restrictSearchableAttributesItem + ) { + if (this.restrictSearchableAttributes == null) { + this.restrictSearchableAttributes = new ArrayList<>(); + } + this.restrictSearchableAttributes.add(restrictSearchableAttributesItem); + return this; + } + + /** + * Restricts a given query to look in only a subset of your searchable attributes. + * + * @return restrictSearchableAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restricts a given query to look in only a subset of your searchable attributes." + ) + public List getRestrictSearchableAttributes() { + return restrictSearchableAttributes; + } + + public void setRestrictSearchableAttributes( + List restrictSearchableAttributes + ) { + this.restrictSearchableAttributes = restrictSearchableAttributes; + } + + public SearchParams ranking(List ranking) { + this.ranking = ranking; + return this; + } + + public SearchParams addRankingItem(String rankingItem) { + if (this.ranking == null) { + this.ranking = new ArrayList<>(); + } + this.ranking.add(rankingItem); + return this; + } + + /** + * Controls how Algolia should sort your results. + * + * @return ranking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Controls how Algolia should sort your results.") + public List getRanking() { + return ranking; + } + + public void setRanking(List ranking) { + this.ranking = ranking; + } + + public SearchParams customRanking(List customRanking) { + this.customRanking = customRanking; + return this; + } + + public SearchParams addCustomRankingItem(String customRankingItem) { + if (this.customRanking == null) { + this.customRanking = new ArrayList<>(); + } + this.customRanking.add(customRankingItem); + return this; + } + + /** + * Specifies the custom ranking criterion. + * + * @return customRanking + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Specifies the custom ranking criterion.") + public List getCustomRanking() { + return customRanking; + } + + public void setCustomRanking(List customRanking) { + this.customRanking = customRanking; + } + + public SearchParams relevancyStrictness(Integer relevancyStrictness) { + this.relevancyStrictness = relevancyStrictness; + return this; + } + + /** + * Controls the relevancy threshold below which less relevant results aren’t included in the + * results. + * + * @return relevancyStrictness + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls the relevancy threshold below which less relevant results aren’t included in" + + " the results." + ) + public Integer getRelevancyStrictness() { + return relevancyStrictness; + } + + public void setRelevancyStrictness(Integer relevancyStrictness) { + this.relevancyStrictness = relevancyStrictness; + } + + public SearchParams attributesToHighlight( + List attributesToHighlight + ) { + this.attributesToHighlight = attributesToHighlight; + return this; + } + + public SearchParams addAttributesToHighlightItem( + String attributesToHighlightItem + ) { + if (this.attributesToHighlight == null) { + this.attributesToHighlight = new ArrayList<>(); + } + this.attributesToHighlight.add(attributesToHighlightItem); + return this; + } + + /** + * List of attributes to highlight. + * + * @return attributesToHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of attributes to highlight.") + public List getAttributesToHighlight() { + return attributesToHighlight; + } + + public void setAttributesToHighlight(List attributesToHighlight) { + this.attributesToHighlight = attributesToHighlight; + } + + public SearchParams attributesToSnippet(List attributesToSnippet) { + this.attributesToSnippet = attributesToSnippet; + return this; + } + + public SearchParams addAttributesToSnippetItem( + String attributesToSnippetItem + ) { + if (this.attributesToSnippet == null) { + this.attributesToSnippet = new ArrayList<>(); + } + this.attributesToSnippet.add(attributesToSnippetItem); + return this; + } + + /** + * List of attributes to snippet, with an optional maximum number of words to snippet. + * + * @return attributesToSnippet + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes to snippet, with an optional maximum number of words to snippet." + ) + public List getAttributesToSnippet() { + return attributesToSnippet; + } + + public void setAttributesToSnippet(List attributesToSnippet) { + this.attributesToSnippet = attributesToSnippet; + } + + public SearchParams highlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + return this; + } + + /** + * The HTML string to insert before the highlighted parts in all highlight and snippet results. + * + * @return highlightPreTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert before the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPreTag() { + return highlightPreTag; + } + + public void setHighlightPreTag(String highlightPreTag) { + this.highlightPreTag = highlightPreTag; + } + + public SearchParams highlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + return this; + } + + /** + * The HTML string to insert after the highlighted parts in all highlight and snippet results. + * + * @return highlightPostTag + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The HTML string to insert after the highlighted parts in all highlight and snippet" + + " results." + ) + public String getHighlightPostTag() { + return highlightPostTag; + } + + public void setHighlightPostTag(String highlightPostTag) { + this.highlightPostTag = highlightPostTag; + } + + public SearchParams snippetEllipsisText(String snippetEllipsisText) { + this.snippetEllipsisText = snippetEllipsisText; + return this; + } + + /** + * String used as an ellipsis indicator when a snippet is truncated. + * + * @return snippetEllipsisText + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "String used as an ellipsis indicator when a snippet is truncated." + ) + public String getSnippetEllipsisText() { + return snippetEllipsisText; + } + + public void setSnippetEllipsisText(String snippetEllipsisText) { + this.snippetEllipsisText = snippetEllipsisText; + } + + public SearchParams restrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + return this; + } + + /** + * Restrict highlighting and snippeting to items that matched the query. + * + * @return restrictHighlightAndSnippetArrays + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Restrict highlighting and snippeting to items that matched the query." + ) + public Boolean getRestrictHighlightAndSnippetArrays() { + return restrictHighlightAndSnippetArrays; + } + + public void setRestrictHighlightAndSnippetArrays( + Boolean restrictHighlightAndSnippetArrays + ) { + this.restrictHighlightAndSnippetArrays = restrictHighlightAndSnippetArrays; + } + + public SearchParams hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public SearchParams minWordSizefor1Typo(Integer minWordSizefor1Typo) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 1 + * typo. + * + * @return minWordSizefor1Typo + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 1 typo." + ) + public Integer getMinWordSizefor1Typo() { + return minWordSizefor1Typo; + } + + public void setMinWordSizefor1Typo(Integer minWordSizefor1Typo) { + this.minWordSizefor1Typo = minWordSizefor1Typo; + } + + public SearchParams minWordSizefor2Typos(Integer minWordSizefor2Typos) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + return this; + } + + /** + * Minimum number of characters a word in the query string must contain to accept matches with 2 + * typos. + * + * @return minWordSizefor2Typos + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Minimum number of characters a word in the query string must contain to accept matches" + + " with 2 typos." + ) + public Integer getMinWordSizefor2Typos() { + return minWordSizefor2Typos; + } + + public void setMinWordSizefor2Typos(Integer minWordSizefor2Typos) { + this.minWordSizefor2Typos = minWordSizefor2Typos; + } + + public SearchParams typoTolerance(TypoToleranceEnum typoTolerance) { + this.typoTolerance = typoTolerance; + return this; + } + + /** + * Controls whether typo tolerance is enabled and how it is applied. + * + * @return typoTolerance + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls whether typo tolerance is enabled and how it is applied." + ) + public TypoToleranceEnum getTypoTolerance() { + return typoTolerance; + } + + public void setTypoTolerance(TypoToleranceEnum typoTolerance) { + this.typoTolerance = typoTolerance; + } + + public SearchParams allowTyposOnNumericTokens( + Boolean allowTyposOnNumericTokens + ) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + return this; + } + + /** + * Whether to allow typos on numbers (“numeric tokens”) in the query string. + * + * @return allowTyposOnNumericTokens + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to allow typos on numbers (“numeric tokens”) in the query string." + ) + public Boolean getAllowTyposOnNumericTokens() { + return allowTyposOnNumericTokens; + } + + public void setAllowTyposOnNumericTokens(Boolean allowTyposOnNumericTokens) { + this.allowTyposOnNumericTokens = allowTyposOnNumericTokens; + } + + public SearchParams disableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + return this; + } + + public SearchParams addDisableTypoToleranceOnAttributesItem( + String disableTypoToleranceOnAttributesItem + ) { + if (this.disableTypoToleranceOnAttributes == null) { + this.disableTypoToleranceOnAttributes = new ArrayList<>(); + } + this.disableTypoToleranceOnAttributes.add( + disableTypoToleranceOnAttributesItem + ); + return this; + } + + /** + * List of attributes on which you want to disable typo tolerance. + * + * @return disableTypoToleranceOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable typo tolerance." + ) + public List getDisableTypoToleranceOnAttributes() { + return disableTypoToleranceOnAttributes; + } + + public void setDisableTypoToleranceOnAttributes( + List disableTypoToleranceOnAttributes + ) { + this.disableTypoToleranceOnAttributes = disableTypoToleranceOnAttributes; + } + + public SearchParams separatorsToIndex(String separatorsToIndex) { + this.separatorsToIndex = separatorsToIndex; + return this; + } + + /** + * Control which separators are indexed. + * + * @return separatorsToIndex + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Control which separators are indexed.") + public String getSeparatorsToIndex() { + return separatorsToIndex; + } + + public void setSeparatorsToIndex(String separatorsToIndex) { + this.separatorsToIndex = separatorsToIndex; + } + + public SearchParams ignorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + return this; + } + + /** + * Treats singular, plurals, and other forms of declensions as matching terms. + * + * @return ignorePlurals + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Treats singular, plurals, and other forms of declensions as matching terms." + ) + public String getIgnorePlurals() { + return ignorePlurals; + } + + public void setIgnorePlurals(String ignorePlurals) { + this.ignorePlurals = ignorePlurals; + } + + public SearchParams removeStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + return this; + } + + /** + * Removes stop (common) words from the query before executing it. + * + * @return removeStopWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Removes stop (common) words from the query before executing it." + ) + public String getRemoveStopWords() { + return removeStopWords; + } + + public void setRemoveStopWords(String removeStopWords) { + this.removeStopWords = removeStopWords; + } + + public SearchParams keepDiacriticsOnCharacters( + String keepDiacriticsOnCharacters + ) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + return this; + } + + /** + * List of characters that the engine shouldn’t automatically normalize. + * + * @return keepDiacriticsOnCharacters + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of characters that the engine shouldn’t automatically normalize." + ) + public String getKeepDiacriticsOnCharacters() { + return keepDiacriticsOnCharacters; + } + + public void setKeepDiacriticsOnCharacters(String keepDiacriticsOnCharacters) { + this.keepDiacriticsOnCharacters = keepDiacriticsOnCharacters; + } + + public SearchParams queryLanguages(List queryLanguages) { + this.queryLanguages = queryLanguages; + return this; + } + + public SearchParams addQueryLanguagesItem(String queryLanguagesItem) { + if (this.queryLanguages == null) { + this.queryLanguages = new ArrayList<>(); + } + this.queryLanguages.add(queryLanguagesItem); + return this; + } + + /** + * Sets the languages to be used by language-specific settings and functionalities such as + * ignorePlurals, removeStopWords, and CJK word-detection. + * + * @return queryLanguages + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Sets the languages to be used by language-specific settings and functionalities such as" + + " ignorePlurals, removeStopWords, and CJK word-detection." + ) + public List getQueryLanguages() { + return queryLanguages; + } + + public void setQueryLanguages(List queryLanguages) { + this.queryLanguages = queryLanguages; + } + + public SearchParams decompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + return this; + } + + /** + * Splits compound words into their composing atoms in the query. + * + * @return decompoundQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Splits compound words into their composing atoms in the query." + ) + public Boolean getDecompoundQuery() { + return decompoundQuery; + } + + public void setDecompoundQuery(Boolean decompoundQuery) { + this.decompoundQuery = decompoundQuery; + } + + public SearchParams enableRules(Boolean enableRules) { + this.enableRules = enableRules; + return this; + } + + /** + * Whether Rules should be globally enabled. + * + * @return enableRules + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Whether Rules should be globally enabled.") + public Boolean getEnableRules() { + return enableRules; + } + + public void setEnableRules(Boolean enableRules) { + this.enableRules = enableRules; + } + + public SearchParams enablePersonalization(Boolean enablePersonalization) { + this.enablePersonalization = enablePersonalization; + return this; + } + + /** + * Enable the Personalization feature. + * + * @return enablePersonalization + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enable the Personalization feature.") + public Boolean getEnablePersonalization() { + return enablePersonalization; + } + + public void setEnablePersonalization(Boolean enablePersonalization) { + this.enablePersonalization = enablePersonalization; + } + + public SearchParams queryType(QueryTypeEnum queryType) { + this.queryType = queryType; + return this; + } + + /** + * Controls if and how query words are interpreted as prefixes. + * + * @return queryType + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls if and how query words are interpreted as prefixes." + ) + public QueryTypeEnum getQueryType() { + return queryType; + } + + public void setQueryType(QueryTypeEnum queryType) { + this.queryType = queryType; + } + + public SearchParams removeWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + return this; + } + + /** + * Selects a strategy to remove words from the query when it doesn’t match any hits. + * + * @return removeWordsIfNoResults + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Selects a strategy to remove words from the query when it doesn’t match any hits." + ) + public RemoveWordsIfNoResultsEnum getRemoveWordsIfNoResults() { + return removeWordsIfNoResults; + } + + public void setRemoveWordsIfNoResults( + RemoveWordsIfNoResultsEnum removeWordsIfNoResults + ) { + this.removeWordsIfNoResults = removeWordsIfNoResults; + } + + public SearchParams advancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + return this; + } + + /** + * Enables the advanced query syntax. + * + * @return advancedSyntax + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables the advanced query syntax.") + public Boolean getAdvancedSyntax() { + return advancedSyntax; + } + + public void setAdvancedSyntax(Boolean advancedSyntax) { + this.advancedSyntax = advancedSyntax; + } + + public SearchParams optionalWords(List optionalWords) { + this.optionalWords = optionalWords; + return this; + } + + public SearchParams addOptionalWordsItem(String optionalWordsItem) { + if (this.optionalWords == null) { + this.optionalWords = new ArrayList<>(); + } + this.optionalWords.add(optionalWordsItem); + return this; + } + + /** + * A list of words that should be considered as optional when found in the query. + * + * @return optionalWords + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A list of words that should be considered as optional when found in the query." + ) + public List getOptionalWords() { + return optionalWords; + } + + public void setOptionalWords(List optionalWords) { + this.optionalWords = optionalWords; + } + + public SearchParams disableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + return this; + } + + public SearchParams addDisableExactOnAttributesItem( + String disableExactOnAttributesItem + ) { + if (this.disableExactOnAttributes == null) { + this.disableExactOnAttributes = new ArrayList<>(); + } + this.disableExactOnAttributes.add(disableExactOnAttributesItem); + return this; + } + + /** + * List of attributes on which you want to disable the exact ranking criterion. + * + * @return disableExactOnAttributes + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of attributes on which you want to disable the exact ranking criterion." + ) + public List getDisableExactOnAttributes() { + return disableExactOnAttributes; + } + + public void setDisableExactOnAttributes( + List disableExactOnAttributes + ) { + this.disableExactOnAttributes = disableExactOnAttributes; + } + + public SearchParams exactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + return this; + } + + /** + * Controls how the exact ranking criterion is computed when the query contains only one word. + * + * @return exactOnSingleWordQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Controls how the exact ranking criterion is computed when the query contains only one" + + " word." + ) + public ExactOnSingleWordQueryEnum getExactOnSingleWordQuery() { + return exactOnSingleWordQuery; + } + + public void setExactOnSingleWordQuery( + ExactOnSingleWordQueryEnum exactOnSingleWordQuery + ) { + this.exactOnSingleWordQuery = exactOnSingleWordQuery; + } + + public SearchParams alternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + return this; + } + + public SearchParams addAlternativesAsExactItem( + AlternativesAsExactEnum alternativesAsExactItem + ) { + if (this.alternativesAsExact == null) { + this.alternativesAsExact = new ArrayList<>(); + } + this.alternativesAsExact.add(alternativesAsExactItem); + return this; + } + + /** + * List of alternatives that should be considered an exact match by the exact ranking criterion. + * + * @return alternativesAsExact + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "List of alternatives that should be considered an exact match by the exact ranking" + + " criterion." + ) + public List getAlternativesAsExact() { + return alternativesAsExact; + } + + public void setAlternativesAsExact( + List alternativesAsExact + ) { + this.alternativesAsExact = alternativesAsExact; + } + + public SearchParams advancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + return this; + } + + public SearchParams addAdvancedSyntaxFeaturesItem( + AdvancedSyntaxFeaturesEnum advancedSyntaxFeaturesItem + ) { + if (this.advancedSyntaxFeatures == null) { + this.advancedSyntaxFeatures = new ArrayList<>(); + } + this.advancedSyntaxFeatures.add(advancedSyntaxFeaturesItem); + return this; + } + + /** + * Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is + * enabled. + * + * @return advancedSyntaxFeatures + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Allows you to specify which advanced syntax features are active when ‘advancedSyntax’ is" + + " enabled." + ) + public List getAdvancedSyntaxFeatures() { + return advancedSyntaxFeatures; + } + + public void setAdvancedSyntaxFeatures( + List advancedSyntaxFeatures + ) { + this.advancedSyntaxFeatures = advancedSyntaxFeatures; + } + + public SearchParams distinct(Integer distinct) { + this.distinct = distinct; + return this; + } + + /** + * Enables de-duplication or grouping of results. minimum: 0 maximum: 4 + * + * @return distinct + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Enables de-duplication or grouping of results.") + public Integer getDistinct() { + return distinct; + } + + public void setDistinct(Integer distinct) { + this.distinct = distinct; + } + + public SearchParams synonyms(Boolean synonyms) { + this.synonyms = synonyms; + return this; + } + + /** + * Whether to take into account an index’s synonyms for a particular search. + * + * @return synonyms + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to take into account an index’s synonyms for a particular search." + ) + public Boolean getSynonyms() { + return synonyms; + } + + public void setSynonyms(Boolean synonyms) { + this.synonyms = synonyms; + } + + public SearchParams replaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + return this; + } + + /** + * Whether to highlight and snippet the original word that matches the synonym or the synonym + * itself. + * + * @return replaceSynonymsInHighlight + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether to highlight and snippet the original word that matches the synonym or the" + + " synonym itself." + ) + public Boolean getReplaceSynonymsInHighlight() { + return replaceSynonymsInHighlight; + } + + public void setReplaceSynonymsInHighlight( + Boolean replaceSynonymsInHighlight + ) { + this.replaceSynonymsInHighlight = replaceSynonymsInHighlight; + } + + public SearchParams minProximity(Integer minProximity) { + this.minProximity = minProximity; + return this; + } + + /** + * Precision of the proximity ranking criterion. minimum: 1 maximum: 7 + * + * @return minProximity + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Precision of the proximity ranking criterion.") + public Integer getMinProximity() { + return minProximity; + } + + public void setMinProximity(Integer minProximity) { + this.minProximity = minProximity; + } + + public SearchParams responseFields(List responseFields) { + this.responseFields = responseFields; + return this; + } + + public SearchParams addResponseFieldsItem(String responseFieldsItem) { + if (this.responseFields == null) { + this.responseFields = new ArrayList<>(); + } + this.responseFields.add(responseFieldsItem); + return this; + } + + /** + * Choose which fields to return in the API response. This parameters applies to search and browse + * queries. + * + * @return responseFields + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Choose which fields to return in the API response. This parameters applies to search and" + + " browse queries." + ) + public List getResponseFields() { + return responseFields; + } + + public void setResponseFields(List responseFields) { + this.responseFields = responseFields; + } + + public SearchParams maxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + return this; + } + + /** + * Maximum number of facet hits to return during a search for facet values. + * + * @return maxFacetHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Maximum number of facet hits to return during a search for facet values." + ) + public Integer getMaxFacetHits() { + return maxFacetHits; + } + + public void setMaxFacetHits(Integer maxFacetHits) { + this.maxFacetHits = maxFacetHits; + } + + public SearchParams attributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + return this; + } + + /** + * When attribute is ranked above proximity in your ranking formula, proximity is used to select + * which searchable attribute is matched in the attribute ranking stage. + * + * @return attributeCriteriaComputedByMinProximity + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "When attribute is ranked above proximity in your ranking formula, proximity is used to" + + " select which searchable attribute is matched in the attribute ranking stage." + ) + public Boolean getAttributeCriteriaComputedByMinProximity() { + return attributeCriteriaComputedByMinProximity; + } + + public void setAttributeCriteriaComputedByMinProximity( + Boolean attributeCriteriaComputedByMinProximity + ) { + this.attributeCriteriaComputedByMinProximity = + attributeCriteriaComputedByMinProximity; + } + + public SearchParams renderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + return this; + } + + /** + * Content defining how the search interface should be rendered. Can be set via the settings for a + * default value and can be overridden via rules. + * + * @return renderingContent + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Content defining how the search interface should be rendered. Can be set via the" + + " settings for a default value and can be overridden via rules." + ) + public Object getRenderingContent() { + return renderingContent; + } + + public void setRenderingContent(Object renderingContent) { + this.renderingContent = renderingContent; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchParams searchParams = (SearchParams) o; + return ( + Objects.equals(this.query, searchParams.query) && + Objects.equals(this.similarQuery, searchParams.similarQuery) && + Objects.equals(this.filters, searchParams.filters) && + Objects.equals(this.facetFilters, searchParams.facetFilters) && + Objects.equals(this.optionalFilters, searchParams.optionalFilters) && + Objects.equals(this.numericFilters, searchParams.numericFilters) && + Objects.equals(this.tagFilters, searchParams.tagFilters) && + Objects.equals( + this.sumOrFiltersScores, + searchParams.sumOrFiltersScores + ) && + Objects.equals(this.facets, searchParams.facets) && + Objects.equals(this.maxValuesPerFacet, searchParams.maxValuesPerFacet) && + Objects.equals( + this.facetingAfterDistinct, + searchParams.facetingAfterDistinct + ) && + Objects.equals(this.sortFacetValuesBy, searchParams.sortFacetValuesBy) && + Objects.equals(this.page, searchParams.page) && + Objects.equals(this.offset, searchParams.offset) && + Objects.equals(this.length, searchParams.length) && + Objects.equals(this.aroundLatLng, searchParams.aroundLatLng) && + Objects.equals(this.aroundLatLngViaIP, searchParams.aroundLatLngViaIP) && + Objects.equals(this.aroundRadius, searchParams.aroundRadius) && + Objects.equals(this.aroundPrecision, searchParams.aroundPrecision) && + Objects.equals( + this.minimumAroundRadius, + searchParams.minimumAroundRadius + ) && + Objects.equals(this.insideBoundingBox, searchParams.insideBoundingBox) && + Objects.equals(this.insidePolygon, searchParams.insidePolygon) && + Objects.equals(this.naturalLanguages, searchParams.naturalLanguages) && + Objects.equals(this.ruleContexts, searchParams.ruleContexts) && + Objects.equals( + this.personalizationImpact, + searchParams.personalizationImpact + ) && + Objects.equals(this.userToken, searchParams.userToken) && + Objects.equals(this.getRankingInfo, searchParams.getRankingInfo) && + Objects.equals(this.clickAnalytics, searchParams.clickAnalytics) && + Objects.equals(this.analytics, searchParams.analytics) && + Objects.equals(this.analyticsTags, searchParams.analyticsTags) && + Objects.equals( + this.percentileComputation, + searchParams.percentileComputation + ) && + Objects.equals(this.enableABTest, searchParams.enableABTest) && + Objects.equals(this.enableReRanking, searchParams.enableReRanking) && + Objects.equals( + this.searchableAttributes, + searchParams.searchableAttributes + ) && + Objects.equals( + this.attributesForFaceting, + searchParams.attributesForFaceting + ) && + Objects.equals( + this.unretrievableAttributes, + searchParams.unretrievableAttributes + ) && + Objects.equals( + this.attributesToRetrieve, + searchParams.attributesToRetrieve + ) && + Objects.equals( + this.restrictSearchableAttributes, + searchParams.restrictSearchableAttributes + ) && + Objects.equals(this.ranking, searchParams.ranking) && + Objects.equals(this.customRanking, searchParams.customRanking) && + Objects.equals( + this.relevancyStrictness, + searchParams.relevancyStrictness + ) && + Objects.equals( + this.attributesToHighlight, + searchParams.attributesToHighlight + ) && + Objects.equals( + this.attributesToSnippet, + searchParams.attributesToSnippet + ) && + Objects.equals(this.highlightPreTag, searchParams.highlightPreTag) && + Objects.equals(this.highlightPostTag, searchParams.highlightPostTag) && + Objects.equals( + this.snippetEllipsisText, + searchParams.snippetEllipsisText + ) && + Objects.equals( + this.restrictHighlightAndSnippetArrays, + searchParams.restrictHighlightAndSnippetArrays + ) && + Objects.equals(this.hitsPerPage, searchParams.hitsPerPage) && + Objects.equals( + this.minWordSizefor1Typo, + searchParams.minWordSizefor1Typo + ) && + Objects.equals( + this.minWordSizefor2Typos, + searchParams.minWordSizefor2Typos + ) && + Objects.equals(this.typoTolerance, searchParams.typoTolerance) && + Objects.equals( + this.allowTyposOnNumericTokens, + searchParams.allowTyposOnNumericTokens + ) && + Objects.equals( + this.disableTypoToleranceOnAttributes, + searchParams.disableTypoToleranceOnAttributes + ) && + Objects.equals(this.separatorsToIndex, searchParams.separatorsToIndex) && + Objects.equals(this.ignorePlurals, searchParams.ignorePlurals) && + Objects.equals(this.removeStopWords, searchParams.removeStopWords) && + Objects.equals( + this.keepDiacriticsOnCharacters, + searchParams.keepDiacriticsOnCharacters + ) && + Objects.equals(this.queryLanguages, searchParams.queryLanguages) && + Objects.equals(this.decompoundQuery, searchParams.decompoundQuery) && + Objects.equals(this.enableRules, searchParams.enableRules) && + Objects.equals( + this.enablePersonalization, + searchParams.enablePersonalization + ) && + Objects.equals(this.queryType, searchParams.queryType) && + Objects.equals( + this.removeWordsIfNoResults, + searchParams.removeWordsIfNoResults + ) && + Objects.equals(this.advancedSyntax, searchParams.advancedSyntax) && + Objects.equals(this.optionalWords, searchParams.optionalWords) && + Objects.equals( + this.disableExactOnAttributes, + searchParams.disableExactOnAttributes + ) && + Objects.equals( + this.exactOnSingleWordQuery, + searchParams.exactOnSingleWordQuery + ) && + Objects.equals( + this.alternativesAsExact, + searchParams.alternativesAsExact + ) && + Objects.equals( + this.advancedSyntaxFeatures, + searchParams.advancedSyntaxFeatures + ) && + Objects.equals(this.distinct, searchParams.distinct) && + Objects.equals(this.synonyms, searchParams.synonyms) && + Objects.equals( + this.replaceSynonymsInHighlight, + searchParams.replaceSynonymsInHighlight + ) && + Objects.equals(this.minProximity, searchParams.minProximity) && + Objects.equals(this.responseFields, searchParams.responseFields) && + Objects.equals(this.maxFacetHits, searchParams.maxFacetHits) && + Objects.equals( + this.attributeCriteriaComputedByMinProximity, + searchParams.attributeCriteriaComputedByMinProximity + ) && + Objects.equals(this.renderingContent, searchParams.renderingContent) + ); + } + + private static boolean equalsNullable( + JsonNullable a, + JsonNullable b + ) { + return ( + a == b || + ( + a != null && + b != null && + a.isPresent() && + b.isPresent() && + Objects.deepEquals(a.get(), b.get()) + ) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + query, + similarQuery, + filters, + facetFilters, + optionalFilters, + numericFilters, + tagFilters, + sumOrFiltersScores, + facets, + maxValuesPerFacet, + facetingAfterDistinct, + sortFacetValuesBy, + page, + offset, + length, + aroundLatLng, + aroundLatLngViaIP, + aroundRadius, + aroundPrecision, + minimumAroundRadius, + insideBoundingBox, + insidePolygon, + naturalLanguages, + ruleContexts, + personalizationImpact, + userToken, + getRankingInfo, + clickAnalytics, + analytics, + analyticsTags, + percentileComputation, + enableABTest, + enableReRanking, + searchableAttributes, + attributesForFaceting, + unretrievableAttributes, + attributesToRetrieve, + restrictSearchableAttributes, + ranking, + customRanking, + relevancyStrictness, + attributesToHighlight, + attributesToSnippet, + highlightPreTag, + highlightPostTag, + snippetEllipsisText, + restrictHighlightAndSnippetArrays, + hitsPerPage, + minWordSizefor1Typo, + minWordSizefor2Typos, + typoTolerance, + allowTyposOnNumericTokens, + disableTypoToleranceOnAttributes, + separatorsToIndex, + ignorePlurals, + removeStopWords, + keepDiacriticsOnCharacters, + queryLanguages, + decompoundQuery, + enableRules, + enablePersonalization, + queryType, + removeWordsIfNoResults, + advancedSyntax, + optionalWords, + disableExactOnAttributes, + exactOnSingleWordQuery, + alternativesAsExact, + advancedSyntaxFeatures, + distinct, + synonyms, + replaceSynonymsInHighlight, + minProximity, + responseFields, + maxFacetHits, + attributeCriteriaComputedByMinProximity, + renderingContent + ); + } + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[] { a.get() }) : 31; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchParams {\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb + .append(" similarQuery: ") + .append(toIndentedString(similarQuery)) + .append("\n"); + sb.append(" filters: ").append(toIndentedString(filters)).append("\n"); + sb + .append(" facetFilters: ") + .append(toIndentedString(facetFilters)) + .append("\n"); + sb + .append(" optionalFilters: ") + .append(toIndentedString(optionalFilters)) + .append("\n"); + sb + .append(" numericFilters: ") + .append(toIndentedString(numericFilters)) + .append("\n"); + sb + .append(" tagFilters: ") + .append(toIndentedString(tagFilters)) + .append("\n"); + sb + .append(" sumOrFiltersScores: ") + .append(toIndentedString(sumOrFiltersScores)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb + .append(" maxValuesPerFacet: ") + .append(toIndentedString(maxValuesPerFacet)) + .append("\n"); + sb + .append(" facetingAfterDistinct: ") + .append(toIndentedString(facetingAfterDistinct)) + .append("\n"); + sb + .append(" sortFacetValuesBy: ") + .append(toIndentedString(sortFacetValuesBy)) + .append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" offset: ").append(toIndentedString(offset)).append("\n"); + sb.append(" length: ").append(toIndentedString(length)).append("\n"); + sb + .append(" aroundLatLng: ") + .append(toIndentedString(aroundLatLng)) + .append("\n"); + sb + .append(" aroundLatLngViaIP: ") + .append(toIndentedString(aroundLatLngViaIP)) + .append("\n"); + sb + .append(" aroundRadius: ") + .append(toIndentedString(aroundRadius)) + .append("\n"); + sb + .append(" aroundPrecision: ") + .append(toIndentedString(aroundPrecision)) + .append("\n"); + sb + .append(" minimumAroundRadius: ") + .append(toIndentedString(minimumAroundRadius)) + .append("\n"); + sb + .append(" insideBoundingBox: ") + .append(toIndentedString(insideBoundingBox)) + .append("\n"); + sb + .append(" insidePolygon: ") + .append(toIndentedString(insidePolygon)) + .append("\n"); + sb + .append(" naturalLanguages: ") + .append(toIndentedString(naturalLanguages)) + .append("\n"); + sb + .append(" ruleContexts: ") + .append(toIndentedString(ruleContexts)) + .append("\n"); + sb + .append(" personalizationImpact: ") + .append(toIndentedString(personalizationImpact)) + .append("\n"); + sb + .append(" userToken: ") + .append(toIndentedString(userToken)) + .append("\n"); + sb + .append(" getRankingInfo: ") + .append(toIndentedString(getRankingInfo)) + .append("\n"); + sb + .append(" clickAnalytics: ") + .append(toIndentedString(clickAnalytics)) + .append("\n"); + sb + .append(" analytics: ") + .append(toIndentedString(analytics)) + .append("\n"); + sb + .append(" analyticsTags: ") + .append(toIndentedString(analyticsTags)) + .append("\n"); + sb + .append(" percentileComputation: ") + .append(toIndentedString(percentileComputation)) + .append("\n"); + sb + .append(" enableABTest: ") + .append(toIndentedString(enableABTest)) + .append("\n"); + sb + .append(" enableReRanking: ") + .append(toIndentedString(enableReRanking)) + .append("\n"); + sb + .append(" searchableAttributes: ") + .append(toIndentedString(searchableAttributes)) + .append("\n"); + sb + .append(" attributesForFaceting: ") + .append(toIndentedString(attributesForFaceting)) + .append("\n"); + sb + .append(" unretrievableAttributes: ") + .append(toIndentedString(unretrievableAttributes)) + .append("\n"); + sb + .append(" attributesToRetrieve: ") + .append(toIndentedString(attributesToRetrieve)) + .append("\n"); + sb + .append(" restrictSearchableAttributes: ") + .append(toIndentedString(restrictSearchableAttributes)) + .append("\n"); + sb.append(" ranking: ").append(toIndentedString(ranking)).append("\n"); + sb + .append(" customRanking: ") + .append(toIndentedString(customRanking)) + .append("\n"); + sb + .append(" relevancyStrictness: ") + .append(toIndentedString(relevancyStrictness)) + .append("\n"); + sb + .append(" attributesToHighlight: ") + .append(toIndentedString(attributesToHighlight)) + .append("\n"); + sb + .append(" attributesToSnippet: ") + .append(toIndentedString(attributesToSnippet)) + .append("\n"); + sb + .append(" highlightPreTag: ") + .append(toIndentedString(highlightPreTag)) + .append("\n"); + sb + .append(" highlightPostTag: ") + .append(toIndentedString(highlightPostTag)) + .append("\n"); + sb + .append(" snippetEllipsisText: ") + .append(toIndentedString(snippetEllipsisText)) + .append("\n"); + sb + .append(" restrictHighlightAndSnippetArrays: ") + .append(toIndentedString(restrictHighlightAndSnippetArrays)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb + .append(" minWordSizefor1Typo: ") + .append(toIndentedString(minWordSizefor1Typo)) + .append("\n"); + sb + .append(" minWordSizefor2Typos: ") + .append(toIndentedString(minWordSizefor2Typos)) + .append("\n"); + sb + .append(" typoTolerance: ") + .append(toIndentedString(typoTolerance)) + .append("\n"); + sb + .append(" allowTyposOnNumericTokens: ") + .append(toIndentedString(allowTyposOnNumericTokens)) + .append("\n"); + sb + .append(" disableTypoToleranceOnAttributes: ") + .append(toIndentedString(disableTypoToleranceOnAttributes)) + .append("\n"); + sb + .append(" separatorsToIndex: ") + .append(toIndentedString(separatorsToIndex)) + .append("\n"); + sb + .append(" ignorePlurals: ") + .append(toIndentedString(ignorePlurals)) + .append("\n"); + sb + .append(" removeStopWords: ") + .append(toIndentedString(removeStopWords)) + .append("\n"); + sb + .append(" keepDiacriticsOnCharacters: ") + .append(toIndentedString(keepDiacriticsOnCharacters)) + .append("\n"); + sb + .append(" queryLanguages: ") + .append(toIndentedString(queryLanguages)) + .append("\n"); + sb + .append(" decompoundQuery: ") + .append(toIndentedString(decompoundQuery)) + .append("\n"); + sb + .append(" enableRules: ") + .append(toIndentedString(enableRules)) + .append("\n"); + sb + .append(" enablePersonalization: ") + .append(toIndentedString(enablePersonalization)) + .append("\n"); + sb + .append(" queryType: ") + .append(toIndentedString(queryType)) + .append("\n"); + sb + .append(" removeWordsIfNoResults: ") + .append(toIndentedString(removeWordsIfNoResults)) + .append("\n"); + sb + .append(" advancedSyntax: ") + .append(toIndentedString(advancedSyntax)) + .append("\n"); + sb + .append(" optionalWords: ") + .append(toIndentedString(optionalWords)) + .append("\n"); + sb + .append(" disableExactOnAttributes: ") + .append(toIndentedString(disableExactOnAttributes)) + .append("\n"); + sb + .append(" exactOnSingleWordQuery: ") + .append(toIndentedString(exactOnSingleWordQuery)) + .append("\n"); + sb + .append(" alternativesAsExact: ") + .append(toIndentedString(alternativesAsExact)) + .append("\n"); + sb + .append(" advancedSyntaxFeatures: ") + .append(toIndentedString(advancedSyntaxFeatures)) + .append("\n"); + sb.append(" distinct: ").append(toIndentedString(distinct)).append("\n"); + sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n"); + sb + .append(" replaceSynonymsInHighlight: ") + .append(toIndentedString(replaceSynonymsInHighlight)) + .append("\n"); + sb + .append(" minProximity: ") + .append(toIndentedString(minProximity)) + .append("\n"); + sb + .append(" responseFields: ") + .append(toIndentedString(responseFields)) + .append("\n"); + sb + .append(" maxFacetHits: ") + .append(toIndentedString(maxFacetHits)) + .append("\n"); + sb + .append(" attributeCriteriaComputedByMinProximity: ") + .append(toIndentedString(attributeCriteriaComputedByMinProximity)) + .append("\n"); + sb + .append(" renderingContent: ") + .append(toIndentedString(renderingContent)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchResponse.java new file mode 100644 index 00000000000..2bb7c74206c --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchResponse.java @@ -0,0 +1,903 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +/** SearchResponse */ +public class SearchResponse { + + public static final String SERIALIZED_NAME_AB_TEST_I_D = "abTestID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_I_D) + private Integer abTestID; + + public static final String SERIALIZED_NAME_AB_TEST_VARIANT_I_D = + "abTestVariantID"; + + @SerializedName(SERIALIZED_NAME_AB_TEST_VARIANT_I_D) + private Integer abTestVariantID; + + public static final String SERIALIZED_NAME_AROUND_LAT_LNG = "aroundLatLng"; + + @SerializedName(SERIALIZED_NAME_AROUND_LAT_LNG) + private String aroundLatLng; + + public static final String SERIALIZED_NAME_AUTOMATIC_RADIUS = + "automaticRadius"; + + @SerializedName(SERIALIZED_NAME_AUTOMATIC_RADIUS) + private String automaticRadius; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT = + "exhaustiveFacetsCount"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_FACETS_COUNT) + private Boolean exhaustiveFacetsCount; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_NB_HITS = + "exhaustiveNbHits"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_NB_HITS) + private Boolean exhaustiveNbHits; + + public static final String SERIALIZED_NAME_EXHAUSTIVE_TYPO = "exhaustiveTypo"; + + @SerializedName(SERIALIZED_NAME_EXHAUSTIVE_TYPO) + private Boolean exhaustiveTypo; + + public static final String SERIALIZED_NAME_FACETS = "facets"; + + @SerializedName(SERIALIZED_NAME_FACETS) + private Map> facets = null; + + public static final String SERIALIZED_NAME_FACETS_STATS = "facets_stats"; + + @SerializedName(SERIALIZED_NAME_FACETS_STATS) + private Map facetsStats = null; + + public static final String SERIALIZED_NAME_HITS_PER_PAGE = "hitsPerPage"; + + @SerializedName(SERIALIZED_NAME_HITS_PER_PAGE) + private Integer hitsPerPage = 20; + + public static final String SERIALIZED_NAME_INDEX = "index"; + + @SerializedName(SERIALIZED_NAME_INDEX) + private String index; + + public static final String SERIALIZED_NAME_INDEX_USED = "indexUsed"; + + @SerializedName(SERIALIZED_NAME_INDEX_USED) + private String indexUsed; + + public static final String SERIALIZED_NAME_MESSAGE = "message"; + + @SerializedName(SERIALIZED_NAME_MESSAGE) + private String message; + + public static final String SERIALIZED_NAME_NB_HITS = "nbHits"; + + @SerializedName(SERIALIZED_NAME_NB_HITS) + private Integer nbHits; + + public static final String SERIALIZED_NAME_NB_PAGES = "nbPages"; + + @SerializedName(SERIALIZED_NAME_NB_PAGES) + private Integer nbPages; + + public static final String SERIALIZED_NAME_NB_SORTED_HITS = "nbSortedHits"; + + @SerializedName(SERIALIZED_NAME_NB_SORTED_HITS) + private Integer nbSortedHits; + + public static final String SERIALIZED_NAME_PAGE = "page"; + + @SerializedName(SERIALIZED_NAME_PAGE) + private Integer page = 0; + + public static final String SERIALIZED_NAME_PARAMS = "params"; + + @SerializedName(SERIALIZED_NAME_PARAMS) + private String params; + + public static final String SERIALIZED_NAME_PARSED_QUERY = "parsedQuery"; + + @SerializedName(SERIALIZED_NAME_PARSED_QUERY) + private String parsedQuery; + + public static final String SERIALIZED_NAME_PROCESSING_TIME_M_S = + "processingTimeMS"; + + @SerializedName(SERIALIZED_NAME_PROCESSING_TIME_M_S) + private Integer processingTimeMS; + + public static final String SERIALIZED_NAME_QUERY = "query"; + + @SerializedName(SERIALIZED_NAME_QUERY) + private String query = ""; + + public static final String SERIALIZED_NAME_QUERY_AFTER_REMOVAL = + "queryAfterRemoval"; + + @SerializedName(SERIALIZED_NAME_QUERY_AFTER_REMOVAL) + private String queryAfterRemoval; + + public static final String SERIALIZED_NAME_SERVER_USED = "serverUsed"; + + @SerializedName(SERIALIZED_NAME_SERVER_USED) + private String serverUsed; + + public static final String SERIALIZED_NAME_USER_DATA = "userData"; + + @SerializedName(SERIALIZED_NAME_USER_DATA) + private Map userData = null; + + public static final String SERIALIZED_NAME_HITS = "hits"; + + @SerializedName(SERIALIZED_NAME_HITS) + private List hits = new ArrayList<>(); + + public SearchResponse abTestID(Integer abTestID) { + this.abTestID = abTestID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestID reports the ongoing A/B test + * ID. + * + * @return abTestID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestID reports the ongoing" + + " A/B test ID." + ) + public Integer getAbTestID() { + return abTestID; + } + + public void setAbTestID(Integer abTestID) { + this.abTestID = abTestID; + } + + public SearchResponse abTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + return this; + } + + /** + * If a search encounters an index that is being A/B tested, abTestVariantID reports the variant + * ID of the index used. + * + * @return abTestVariantID + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "If a search encounters an index that is being A/B tested, abTestVariantID reports the" + + " variant ID of the index used." + ) + public Integer getAbTestVariantID() { + return abTestVariantID; + } + + public void setAbTestVariantID(Integer abTestVariantID) { + this.abTestVariantID = abTestVariantID; + } + + public SearchResponse aroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + return this; + } + + /** + * The computed geo location. + * + * @return aroundLatLng + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "The computed geo location.") + public String getAroundLatLng() { + return aroundLatLng; + } + + public void setAroundLatLng(String aroundLatLng) { + this.aroundLatLng = aroundLatLng; + } + + public SearchResponse automaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + return this; + } + + /** + * The automatically computed radius. For legacy reasons, this parameter is a string and not an + * integer. + * + * @return automaticRadius + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The automatically computed radius. For legacy reasons, this parameter is a string and" + + " not an integer." + ) + public String getAutomaticRadius() { + return automaticRadius; + } + + public void setAutomaticRadius(String automaticRadius) { + this.automaticRadius = automaticRadius; + } + + public SearchResponse exhaustiveFacetsCount(Boolean exhaustiveFacetsCount) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + return this; + } + + /** + * Whether the facet count is exhaustive or approximate. + * + * @return exhaustiveFacetsCount + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Whether the facet count is exhaustive or approximate." + ) + public Boolean getExhaustiveFacetsCount() { + return exhaustiveFacetsCount; + } + + public void setExhaustiveFacetsCount(Boolean exhaustiveFacetsCount) { + this.exhaustiveFacetsCount = exhaustiveFacetsCount; + } + + public SearchResponse exhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + return this; + } + + /** + * Indicate if the nbHits count was exhaustive or approximate + * + * @return exhaustiveNbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the nbHits count was exhaustive or approximate" + ) + public Boolean getExhaustiveNbHits() { + return exhaustiveNbHits; + } + + public void setExhaustiveNbHits(Boolean exhaustiveNbHits) { + this.exhaustiveNbHits = exhaustiveNbHits; + } + + public SearchResponse exhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + return this; + } + + /** + * Indicate if the typo-tolerence search was exhaustive or approximate (only included when + * typo-tolerance is enabled) + * + * @return exhaustiveTypo + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Indicate if the typo-tolerence search was exhaustive or approximate (only included when" + + " typo-tolerance is enabled)" + ) + public Boolean getExhaustiveTypo() { + return exhaustiveTypo; + } + + public void setExhaustiveTypo(Boolean exhaustiveTypo) { + this.exhaustiveTypo = exhaustiveTypo; + } + + public SearchResponse facets(Map> facets) { + this.facets = facets; + return this; + } + + public SearchResponse putFacetsItem( + String key, + Map facetsItem + ) { + if (this.facets == null) { + this.facets = new HashMap<>(); + } + this.facets.put(key, facetsItem); + return this; + } + + /** + * A mapping of each facet name to the corresponding facet counts. + * + * @return facets + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "{\"category\":{\"food\":1,\"tech\":42}}", + value = "A mapping of each facet name to the corresponding facet counts." + ) + public Map> getFacets() { + return facets; + } + + public void setFacets(Map> facets) { + this.facets = facets; + } + + public SearchResponse facetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + return this; + } + + public SearchResponse putFacetsStatsItem( + String key, + BaseSearchResponseFacetsStats facetsStatsItem + ) { + if (this.facetsStats == null) { + this.facetsStats = new HashMap<>(); + } + this.facetsStats.put(key, facetsStatsItem); + return this; + } + + /** + * Statistics for numerical facets. + * + * @return facetsStats + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Statistics for numerical facets.") + public Map getFacetsStats() { + return facetsStats; + } + + public void setFacetsStats( + Map facetsStats + ) { + this.facetsStats = facetsStats; + } + + public SearchResponse hitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + return this; + } + + /** + * Set the number of hits per page. + * + * @return hitsPerPage + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Set the number of hits per page.") + public Integer getHitsPerPage() { + return hitsPerPage; + } + + public void setHitsPerPage(Integer hitsPerPage) { + this.hitsPerPage = hitsPerPage; + } + + public SearchResponse index(String index) { + this.index = index; + return this; + } + + /** + * Index name used for the query. + * + * @return index + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexName", + value = "Index name used for the query." + ) + public String getIndex() { + return index; + } + + public void setIndex(String index) { + this.index = index; + } + + public SearchResponse indexUsed(String indexUsed) { + this.indexUsed = indexUsed; + return this; + } + + /** + * Index name used for the query. In the case of an A/B test, the targeted index isn’t always the + * index used by the query. + * + * @return indexUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "indexNameAlt", + value = "Index name used for the query. In the case of an A/B test, the targeted index isn’t" + + " always the index used by the query." + ) + public String getIndexUsed() { + return indexUsed; + } + + public void setIndexUsed(String indexUsed) { + this.indexUsed = indexUsed; + } + + public SearchResponse message(String message) { + this.message = message; + return this; + } + + /** + * Used to return warnings about the query. + * + * @return message + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Used to return warnings about the query.") + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public SearchResponse nbHits(Integer nbHits) { + this.nbHits = nbHits; + return this; + } + + /** + * Number of hits that the search query matched + * + * @return nbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Number of hits that the search query matched" + ) + public Integer getNbHits() { + return nbHits; + } + + public void setNbHits(Integer nbHits) { + this.nbHits = nbHits; + } + + public SearchResponse nbPages(Integer nbPages) { + this.nbPages = nbPages; + return this; + } + + /** + * Number of pages available for the current query + * + * @return nbPages + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "1", + required = true, + value = "Number of pages available for the current query" + ) + public Integer getNbPages() { + return nbPages; + } + + public void setNbPages(Integer nbPages) { + this.nbPages = nbPages; + } + + public SearchResponse nbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + return this; + } + + /** + * The number of hits selected and sorted by the relevant sort algorithm + * + * @return nbSortedHits + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "20", + value = "The number of hits selected and sorted by the relevant sort algorithm" + ) + public Integer getNbSortedHits() { + return nbSortedHits; + } + + public void setNbSortedHits(Integer nbSortedHits) { + this.nbSortedHits = nbSortedHits; + } + + public SearchResponse page(Integer page) { + this.page = page; + return this; + } + + /** + * Specify the page to retrieve. + * + * @return page + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Specify the page to retrieve.") + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public SearchResponse params(String params) { + this.params = params; + return this; + } + + /** + * A url-encoded string of all search parameters. + * + * @return params + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "query=a&hitsPerPage=20", + required = true, + value = "A url-encoded string of all search parameters." + ) + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + + public SearchResponse parsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + return this; + } + + /** + * The query string that will be searched, after normalization. + * + * @return parsedQuery + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "The query string that will be searched, after normalization." + ) + public String getParsedQuery() { + return parsedQuery; + } + + public void setParsedQuery(String parsedQuery) { + this.parsedQuery = parsedQuery; + } + + public SearchResponse processingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + return this; + } + + /** + * Time the server took to process the request, in milliseconds. + * + * @return processingTimeMS + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Time the server took to process the request, in milliseconds." + ) + public Integer getProcessingTimeMS() { + return processingTimeMS; + } + + public void setProcessingTimeMS(Integer processingTimeMS) { + this.processingTimeMS = processingTimeMS; + } + + public SearchResponse query(String query) { + this.query = query; + return this; + } + + /** + * The text to search in the index. + * + * @return query + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "The text to search in the index.") + public String getQuery() { + return query; + } + + public void setQuery(String query) { + this.query = query; + } + + public SearchResponse queryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + return this; + } + + /** + * A markup text indicating which parts of the original query have been removed in order to + * retrieve a non-empty result set. + * + * @return queryAfterRemoval + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "A markup text indicating which parts of the original query have been removed in order to" + + " retrieve a non-empty result set." + ) + public String getQueryAfterRemoval() { + return queryAfterRemoval; + } + + public void setQueryAfterRemoval(String queryAfterRemoval) { + this.queryAfterRemoval = queryAfterRemoval; + } + + public SearchResponse serverUsed(String serverUsed) { + this.serverUsed = serverUsed; + return this; + } + + /** + * Actual host name of the server that processed the request. + * + * @return serverUsed + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Actual host name of the server that processed the request." + ) + public String getServerUsed() { + return serverUsed; + } + + public void setServerUsed(String serverUsed) { + this.serverUsed = serverUsed; + } + + public SearchResponse userData(Map userData) { + this.userData = userData; + return this; + } + + public SearchResponse putUserDataItem(String key, Object userDataItem) { + if (this.userData == null) { + this.userData = new HashMap<>(); + } + this.userData.put(key, userDataItem); + return this; + } + + /** + * Lets you store custom data in your indices. + * + * @return userData + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Lets you store custom data in your indices.") + public Map getUserData() { + return userData; + } + + public void setUserData(Map userData) { + this.userData = userData; + } + + public SearchResponse hits(List hits) { + this.hits = hits; + return this; + } + + public SearchResponse addHitsItem(Record hitsItem) { + this.hits.add(hitsItem); + return this; + } + + /** + * Get hits + * + * @return hits + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "") + public List getHits() { + return hits; + } + + public void setHits(List hits) { + this.hits = hits; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchResponse searchResponse = (SearchResponse) o; + return ( + Objects.equals(this.abTestID, searchResponse.abTestID) && + Objects.equals(this.abTestVariantID, searchResponse.abTestVariantID) && + Objects.equals(this.aroundLatLng, searchResponse.aroundLatLng) && + Objects.equals(this.automaticRadius, searchResponse.automaticRadius) && + Objects.equals( + this.exhaustiveFacetsCount, + searchResponse.exhaustiveFacetsCount + ) && + Objects.equals(this.exhaustiveNbHits, searchResponse.exhaustiveNbHits) && + Objects.equals(this.exhaustiveTypo, searchResponse.exhaustiveTypo) && + Objects.equals(this.facets, searchResponse.facets) && + Objects.equals(this.facetsStats, searchResponse.facetsStats) && + Objects.equals(this.hitsPerPage, searchResponse.hitsPerPage) && + Objects.equals(this.index, searchResponse.index) && + Objects.equals(this.indexUsed, searchResponse.indexUsed) && + Objects.equals(this.message, searchResponse.message) && + Objects.equals(this.nbHits, searchResponse.nbHits) && + Objects.equals(this.nbPages, searchResponse.nbPages) && + Objects.equals(this.nbSortedHits, searchResponse.nbSortedHits) && + Objects.equals(this.page, searchResponse.page) && + Objects.equals(this.params, searchResponse.params) && + Objects.equals(this.parsedQuery, searchResponse.parsedQuery) && + Objects.equals(this.processingTimeMS, searchResponse.processingTimeMS) && + Objects.equals(this.query, searchResponse.query) && + Objects.equals( + this.queryAfterRemoval, + searchResponse.queryAfterRemoval + ) && + Objects.equals(this.serverUsed, searchResponse.serverUsed) && + Objects.equals(this.userData, searchResponse.userData) && + Objects.equals(this.hits, searchResponse.hits) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + abTestID, + abTestVariantID, + aroundLatLng, + automaticRadius, + exhaustiveFacetsCount, + exhaustiveNbHits, + exhaustiveTypo, + facets, + facetsStats, + hitsPerPage, + index, + indexUsed, + message, + nbHits, + nbPages, + nbSortedHits, + page, + params, + parsedQuery, + processingTimeMS, + query, + queryAfterRemoval, + serverUsed, + userData, + hits + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchResponse {\n"); + sb.append(" abTestID: ").append(toIndentedString(abTestID)).append("\n"); + sb + .append(" abTestVariantID: ") + .append(toIndentedString(abTestVariantID)) + .append("\n"); + sb + .append(" aroundLatLng: ") + .append(toIndentedString(aroundLatLng)) + .append("\n"); + sb + .append(" automaticRadius: ") + .append(toIndentedString(automaticRadius)) + .append("\n"); + sb + .append(" exhaustiveFacetsCount: ") + .append(toIndentedString(exhaustiveFacetsCount)) + .append("\n"); + sb + .append(" exhaustiveNbHits: ") + .append(toIndentedString(exhaustiveNbHits)) + .append("\n"); + sb + .append(" exhaustiveTypo: ") + .append(toIndentedString(exhaustiveTypo)) + .append("\n"); + sb.append(" facets: ").append(toIndentedString(facets)).append("\n"); + sb + .append(" facetsStats: ") + .append(toIndentedString(facetsStats)) + .append("\n"); + sb + .append(" hitsPerPage: ") + .append(toIndentedString(hitsPerPage)) + .append("\n"); + sb.append(" index: ").append(toIndentedString(index)).append("\n"); + sb + .append(" indexUsed: ") + .append(toIndentedString(indexUsed)) + .append("\n"); + sb.append(" message: ").append(toIndentedString(message)).append("\n"); + sb.append(" nbHits: ").append(toIndentedString(nbHits)).append("\n"); + sb.append(" nbPages: ").append(toIndentedString(nbPages)).append("\n"); + sb + .append(" nbSortedHits: ") + .append(toIndentedString(nbSortedHits)) + .append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" params: ").append(toIndentedString(params)).append("\n"); + sb + .append(" parsedQuery: ") + .append(toIndentedString(parsedQuery)) + .append("\n"); + sb + .append(" processingTimeMS: ") + .append(toIndentedString(processingTimeMS)) + .append("\n"); + sb.append(" query: ").append(toIndentedString(query)).append("\n"); + sb + .append(" queryAfterRemoval: ") + .append(toIndentedString(queryAfterRemoval)) + .append("\n"); + sb + .append(" serverUsed: ") + .append(toIndentedString(serverUsed)) + .append("\n"); + sb.append(" userData: ").append(toIndentedString(userData)).append("\n"); + sb.append(" hits: ").append(toIndentedString(hits)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchSynonymsResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchSynonymsResponse.java new file mode 100644 index 00000000000..c4153d718d1 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SearchSynonymsResponse.java @@ -0,0 +1,113 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Objects; + +/** SearchSynonymsResponse */ +public class SearchSynonymsResponse extends HashMap { + + public static final String SERIALIZED_NAME_HITS = "hits"; + + @SerializedName(SERIALIZED_NAME_HITS) + private List hits = new ArrayList<>(); + + public static final String SERIALIZED_NAME_NB_HITS = "nbHits"; + + @SerializedName(SERIALIZED_NAME_NB_HITS) + private Integer nbHits; + + public SearchSynonymsResponse hits(List hits) { + this.hits = hits; + return this; + } + + public SearchSynonymsResponse addHitsItem(SynonymHit hitsItem) { + this.hits.add(hitsItem); + return this; + } + + /** + * Array of synonym objects. + * + * @return hits + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Array of synonym objects.") + public List getHits() { + return hits; + } + + public void setHits(List hits) { + this.hits = hits; + } + + public SearchSynonymsResponse nbHits(Integer nbHits) { + this.nbHits = nbHits; + return this; + } + + /** + * Number of hits that the search query matched + * + * @return nbHits + */ + @javax.annotation.Nonnull + @ApiModelProperty( + example = "20", + required = true, + value = "Number of hits that the search query matched" + ) + public Integer getNbHits() { + return nbHits; + } + + public void setNbHits(Integer nbHits) { + this.nbHits = nbHits; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SearchSynonymsResponse searchSynonymsResponse = (SearchSynonymsResponse) o; + return ( + Objects.equals(this.hits, searchSynonymsResponse.hits) && + Objects.equals(this.nbHits, searchSynonymsResponse.nbHits) && + super.equals(o) + ); + } + + @Override + public int hashCode() { + return Objects.hash(hits, nbHits, super.hashCode()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SearchSynonymsResponse {\n"); + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + sb.append(" hits: ").append(toIndentedString(hits)).append("\n"); + sb.append(" nbHits: ").append(toIndentedString(nbHits)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SetSettingsResponse.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SetSettingsResponse.java new file mode 100644 index 00000000000..bdb6ef85d2a --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SetSettingsResponse.java @@ -0,0 +1,103 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModelProperty; +import java.time.OffsetDateTime; +import java.util.Objects; + +/** SetSettingsResponse */ +public class SetSettingsResponse { + + public static final String SERIALIZED_NAME_TASK_I_D = "taskID"; + + @SerializedName(SERIALIZED_NAME_TASK_I_D) + private Integer taskID; + + public static final String SERIALIZED_NAME_UPDATED_AT = "updatedAt"; + + @SerializedName(SERIALIZED_NAME_UPDATED_AT) + private OffsetDateTime updatedAt; + + public SetSettingsResponse taskID(Integer taskID) { + this.taskID = taskID; + return this; + } + + /** + * taskID of the indexing task to wait for. + * + * @return taskID + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "taskID of the indexing task to wait for.") + public Integer getTaskID() { + return taskID; + } + + public void setTaskID(Integer taskID) { + this.taskID = taskID; + } + + public SetSettingsResponse updatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + /** + * Date of last update (ISO-8601 format). + * + * @return updatedAt + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Date of last update (ISO-8601 format).") + public OffsetDateTime getUpdatedAt() { + return updatedAt; + } + + public void setUpdatedAt(OffsetDateTime updatedAt) { + this.updatedAt = updatedAt; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SetSettingsResponse setSettingsResponse = (SetSettingsResponse) o; + return ( + Objects.equals(this.taskID, setSettingsResponse.taskID) && + Objects.equals(this.updatedAt, setSettingsResponse.updatedAt) + ); + } + + @Override + public int hashCode() { + return Objects.hash(taskID, updatedAt); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SetSettingsResponse {\n"); + sb.append(" taskID: ").append(toIndentedString(taskID)).append("\n"); + sb + .append(" updatedAt: ") + .append(toIndentedString(updatedAt)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java new file mode 100644 index 00000000000..f117c587671 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SnippetResult.java @@ -0,0 +1,164 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.Objects; + +/** SnippetResult */ +public class SnippetResult { + + public static final String SERIALIZED_NAME_VALUE = "value"; + + @SerializedName(SERIALIZED_NAME_VALUE) + private String value; + + /** Indicates how well the attribute matched the search query. */ + @JsonAdapter(MatchLevelEnum.Adapter.class) + public enum MatchLevelEnum { + NONE("none"), + + PARTIAL("partial"), + + FULL("full"); + + private String value; + + MatchLevelEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MatchLevelEnum fromValue(String value) { + for (MatchLevelEnum b : MatchLevelEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final MatchLevelEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MatchLevelEnum read(final JsonReader jsonReader) + throws IOException { + String value = jsonReader.nextString(); + return MatchLevelEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_MATCH_LEVEL = "matchLevel"; + + @SerializedName(SERIALIZED_NAME_MATCH_LEVEL) + private MatchLevelEnum matchLevel; + + public SnippetResult value(String value) { + this.value = value; + return this; + } + + /** + * Markup text with occurrences highlighted. + * + * @return value + */ + @javax.annotation.Nullable + @ApiModelProperty( + example = "George Clooney...", + value = "Markup text with occurrences highlighted." + ) + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public SnippetResult matchLevel(MatchLevelEnum matchLevel) { + this.matchLevel = matchLevel; + return this; + } + + /** + * Indicates how well the attribute matched the search query. + * + * @return matchLevel + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Indicates how well the attribute matched the search query." + ) + public MatchLevelEnum getMatchLevel() { + return matchLevel; + } + + public void setMatchLevel(MatchLevelEnum matchLevel) { + this.matchLevel = matchLevel; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SnippetResult snippetResult = (SnippetResult) o; + return ( + Objects.equals(this.value, snippetResult.value) && + Objects.equals(this.matchLevel, snippetResult.matchLevel) + ); + } + + @Override + public int hashCode() { + return Objects.hash(value, matchLevel); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SnippetResult {\n"); + sb.append(" value: ").append(toIndentedString(value)).append("\n"); + sb + .append(" matchLevel: ") + .append(toIndentedString(matchLevel)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHit.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHit.java new file mode 100644 index 00000000000..514cc6431b2 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHit.java @@ -0,0 +1,406 @@ +package com.algolia.model; + +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 io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Synonym object. */ +@ApiModel(description = "Synonym object.") +public class SynonymHit { + + public static final String SERIALIZED_NAME_OBJECT_I_D = "objectID"; + + @SerializedName(SERIALIZED_NAME_OBJECT_I_D) + private String objectID; + + /** Type of the synonym object. */ + @JsonAdapter(TypeEnum.Adapter.class) + public enum TypeEnum { + SYNONYM("synonym"), + + ONEWAYSYNONYM("onewaysynonym"), + + ALTCORRECTION1("altcorrection1"), + + ALTCORRECTION2("altcorrection2"), + + PLACEHOLDER("placeholder"); + + private String value; + + TypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static TypeEnum fromValue(String value) { + for (TypeEnum b : TypeEnum.values()) { + if (b.value.equals(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + + @Override + public void write( + final JsonWriter jsonWriter, + final TypeEnum enumeration + ) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public TypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return TypeEnum.fromValue(value); + } + } + } + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + private TypeEnum type; + + public static final String SERIALIZED_NAME_SYNONYMS = "synonyms"; + + @SerializedName(SERIALIZED_NAME_SYNONYMS) + private List synonyms = null; + + public static final String SERIALIZED_NAME_INPUT = "input"; + + @SerializedName(SERIALIZED_NAME_INPUT) + private String input; + + public static final String SERIALIZED_NAME_WORD = "word"; + + @SerializedName(SERIALIZED_NAME_WORD) + private String word; + + public static final String SERIALIZED_NAME_CORRECTIONS = "corrections"; + + @SerializedName(SERIALIZED_NAME_CORRECTIONS) + private List corrections = null; + + public static final String SERIALIZED_NAME_PLACEHOLDER = "placeholder"; + + @SerializedName(SERIALIZED_NAME_PLACEHOLDER) + private String placeholder; + + public static final String SERIALIZED_NAME_REPLACEMENTS = "replacements"; + + @SerializedName(SERIALIZED_NAME_REPLACEMENTS) + private List replacements = null; + + public static final String SERIALIZED_NAME_HIGHLIGHT_RESULT = + "_highlightResult"; + + @SerializedName(SERIALIZED_NAME_HIGHLIGHT_RESULT) + private SynonymHitHighlightResult highlightResult; + + public SynonymHit objectID(String objectID) { + this.objectID = objectID; + return this; + } + + /** + * Unique identifier of the synonym object to be created or updated. + * + * @return objectID + */ + @javax.annotation.Nonnull + @ApiModelProperty( + required = true, + value = "Unique identifier of the synonym object to be created or updated." + ) + public String getObjectID() { + return objectID; + } + + public void setObjectID(String objectID) { + this.objectID = objectID; + } + + public SynonymHit type(TypeEnum type) { + this.type = type; + return this; + } + + /** + * Type of the synonym object. + * + * @return type + */ + @javax.annotation.Nonnull + @ApiModelProperty(required = true, value = "Type of the synonym object.") + public TypeEnum getType() { + return type; + } + + public void setType(TypeEnum type) { + this.type = type; + } + + public SynonymHit synonyms(List synonyms) { + this.synonyms = synonyms; + return this; + } + + public SynonymHit addSynonymsItem(String synonymsItem) { + if (this.synonyms == null) { + this.synonyms = new ArrayList<>(); + } + this.synonyms.add(synonymsItem); + return this; + } + + /** + * Words or phrases to be considered equivalent. + * + * @return synonyms + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Words or phrases to be considered equivalent.") + public List getSynonyms() { + return synonyms; + } + + public void setSynonyms(List synonyms) { + this.synonyms = synonyms; + } + + public SynonymHit input(String input) { + this.input = input; + return this; + } + + /** + * Word or phrase to appear in query strings (for onewaysynonym). + * + * @return input + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Word or phrase to appear in query strings (for onewaysynonym)." + ) + public String getInput() { + return input; + } + + public void setInput(String input) { + this.input = input; + } + + public SynonymHit word(String word) { + this.word = word; + return this; + } + + /** + * Word or phrase to appear in query strings (for altcorrection1 and altcorrection2). + * + * @return word + */ + @javax.annotation.Nullable + @ApiModelProperty( + value = "Word or phrase to appear in query strings (for altcorrection1 and altcorrection2)." + ) + public String getWord() { + return word; + } + + public void setWord(String word) { + this.word = word; + } + + public SynonymHit corrections(List corrections) { + this.corrections = corrections; + return this; + } + + public SynonymHit addCorrectionsItem(String correctionsItem) { + if (this.corrections == null) { + this.corrections = new ArrayList<>(); + } + this.corrections.add(correctionsItem); + return this; + } + + /** + * Words to be matched in records. + * + * @return corrections + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Words to be matched in records.") + public List getCorrections() { + return corrections; + } + + public void setCorrections(List corrections) { + this.corrections = corrections; + } + + public SynonymHit placeholder(String placeholder) { + this.placeholder = placeholder; + return this; + } + + /** + * Token to be put inside records. + * + * @return placeholder + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "Token to be put inside records.") + public String getPlaceholder() { + return placeholder; + } + + public void setPlaceholder(String placeholder) { + this.placeholder = placeholder; + } + + public SynonymHit replacements(List replacements) { + this.replacements = replacements; + return this; + } + + public SynonymHit addReplacementsItem(String replacementsItem) { + if (this.replacements == null) { + this.replacements = new ArrayList<>(); + } + this.replacements.add(replacementsItem); + return this; + } + + /** + * List of query words that will match the token. + * + * @return replacements + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "List of query words that will match the token.") + public List getReplacements() { + return replacements; + } + + public void setReplacements(List replacements) { + this.replacements = replacements; + } + + public SynonymHit highlightResult(SynonymHitHighlightResult highlightResult) { + this.highlightResult = highlightResult; + return this; + } + + /** + * Get highlightResult + * + * @return highlightResult + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public SynonymHitHighlightResult getHighlightResult() { + return highlightResult; + } + + public void setHighlightResult(SynonymHitHighlightResult highlightResult) { + this.highlightResult = highlightResult; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SynonymHit synonymHit = (SynonymHit) o; + return ( + Objects.equals(this.objectID, synonymHit.objectID) && + Objects.equals(this.type, synonymHit.type) && + Objects.equals(this.synonyms, synonymHit.synonyms) && + Objects.equals(this.input, synonymHit.input) && + Objects.equals(this.word, synonymHit.word) && + Objects.equals(this.corrections, synonymHit.corrections) && + Objects.equals(this.placeholder, synonymHit.placeholder) && + Objects.equals(this.replacements, synonymHit.replacements) && + Objects.equals(this.highlightResult, synonymHit.highlightResult) + ); + } + + @Override + public int hashCode() { + return Objects.hash( + objectID, + type, + synonyms, + input, + word, + corrections, + placeholder, + replacements, + highlightResult + ); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SynonymHit {\n"); + sb.append(" objectID: ").append(toIndentedString(objectID)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" synonyms: ").append(toIndentedString(synonyms)).append("\n"); + sb.append(" input: ").append(toIndentedString(input)).append("\n"); + sb.append(" word: ").append(toIndentedString(word)).append("\n"); + sb + .append(" corrections: ") + .append(toIndentedString(corrections)) + .append("\n"); + sb + .append(" placeholder: ") + .append(toIndentedString(placeholder)) + .append("\n"); + sb + .append(" replacements: ") + .append(toIndentedString(replacements)) + .append("\n"); + sb + .append(" highlightResult: ") + .append(toIndentedString(highlightResult)) + .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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHitHighlightResult.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHitHighlightResult.java new file mode 100644 index 00000000000..ccc0e886e3f --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/model/SynonymHitHighlightResult.java @@ -0,0 +1,113 @@ +package com.algolia.model; + +import com.google.gson.annotations.SerializedName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +/** Highlighted results */ +@ApiModel(description = "Highlighted results") +public class SynonymHitHighlightResult { + + public static final String SERIALIZED_NAME_TYPE = "type"; + + @SerializedName(SERIALIZED_NAME_TYPE) + private HighlightResult type; + + public static final String SERIALIZED_NAME_SYNONYMS = "synonyms"; + + @SerializedName(SERIALIZED_NAME_SYNONYMS) + private List synonyms = null; + + public SynonymHitHighlightResult type(HighlightResult type) { + this.type = type; + return this; + } + + /** + * Get type + * + * @return type + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public HighlightResult getType() { + return type; + } + + public void setType(HighlightResult type) { + this.type = type; + } + + public SynonymHitHighlightResult synonyms(List synonyms) { + this.synonyms = synonyms; + return this; + } + + public SynonymHitHighlightResult addSynonymsItem( + HighlightResult synonymsItem + ) { + if (this.synonyms == null) { + this.synonyms = new ArrayList<>(); + } + this.synonyms.add(synonymsItem); + return this; + } + + /** + * Get synonyms + * + * @return synonyms + */ + @javax.annotation.Nullable + @ApiModelProperty(value = "") + public List getSynonyms() { + return synonyms; + } + + public void setSynonyms(List synonyms) { + this.synonyms = synonyms; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SynonymHitHighlightResult synonymHitHighlightResult = (SynonymHitHighlightResult) o; + return ( + Objects.equals(this.type, synonymHitHighlightResult.type) && + Objects.equals(this.synonyms, synonymHitHighlightResult.synonyms) + ); + } + + @Override + public int hashCode() { + return Objects.hash(type, synonyms); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SynonymHitHighlightResult {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" synonyms: ").append(toIndentedString(synonyms)).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 "); + } +} diff --git a/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java new file mode 100644 index 00000000000..2b534b708d9 --- /dev/null +++ b/clients/algoliasearch-client-java-2/algoliasearch-core/com/algolia/search/SearchApi.java @@ -0,0 +1,2927 @@ +package com.algolia.search; + +import com.algolia.ApiCallback; +import com.algolia.ApiClient; +import com.algolia.ApiException; +import com.algolia.ApiResponse; +import com.algolia.Pair; +import com.algolia.model.BatchObject; +import com.algolia.model.BatchResponse; +import com.algolia.model.ClearAllSynonymsResponse; +import com.algolia.model.DeleteIndexResponse; +import com.algolia.model.DeleteSynonymResponse; +import com.algolia.model.IndexSettings; +import com.algolia.model.ListIndicesResponse; +import com.algolia.model.MultipleQueriesObject; +import com.algolia.model.MultipleQueriesResponse; +import com.algolia.model.OperationIndexObject; +import com.algolia.model.OperationIndexResponse; +import com.algolia.model.SaveObjectResponse; +import com.algolia.model.SaveSynonymResponse; +import com.algolia.model.SaveSynonymsResponse; +import com.algolia.model.SearchParams; +import com.algolia.model.SearchResponse; +import com.algolia.model.SearchSynonymsResponse; +import com.algolia.model.SetSettingsResponse; +import com.algolia.model.SynonymHit; +import com.google.gson.reflect.TypeToken; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class SearchApi extends ApiClient { + + public SearchApi(String appId, String apiKey) { + super(appId, apiKey); + } + + /** + * Build call for batch + * + * @param indexName The index in which to perform the request. (required) + * @param batchObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call batchCall( + String indexName, + BatchObject batchObject, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = batchObject; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/batch".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call batchValidateBeforeCall( + String indexName, + BatchObject batchObject, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling batch(Async)" + ); + } + + // verify the required parameter 'batchObject' is set + if (batchObject == null) { + throw new ApiException( + "Missing the required parameter 'batchObject' when calling batch(Async)" + ); + } + + okhttp3.Call localVarCall = batchCall(indexName, batchObject, _callback); + return localVarCall; + } + + /** + * Performs multiple write operations in a single API call. + * + * @param indexName The index in which to perform the request. (required) + * @param batchObject (required) + * @return BatchResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public BatchResponse batch(String indexName, BatchObject batchObject) + throws ApiException { + ApiResponse localVarResp = batchWithHttpInfo( + indexName, + batchObject + ); + return localVarResp.getData(); + } + + /** + * Performs multiple write operations in a single API call. + * + * @param indexName The index in which to perform the request. (required) + * @param batchObject (required) + * @return ApiResponse<BatchResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse batchWithHttpInfo( + String indexName, + BatchObject batchObject + ) throws ApiException { + okhttp3.Call localVarCall = batchValidateBeforeCall( + indexName, + batchObject, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Performs multiple write operations in a single API call. + * + * @param indexName The index in which to perform the request. (required) + * @param batchObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call batchAsync( + String indexName, + BatchObject batchObject, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = batchValidateBeforeCall( + indexName, + batchObject, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for clearAllSynonyms + * + * @param indexName The index in which to perform the request. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call clearAllSynonymsCall( + String indexName, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/clear".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (forwardToReplicas != null) { + localVarQueryParams.addAll( + this.parameterToPair("forwardToReplicas", forwardToReplicas) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call clearAllSynonymsValidateBeforeCall( + String indexName, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling clearAllSynonyms(Async)" + ); + } + + okhttp3.Call localVarCall = clearAllSynonymsCall( + indexName, + forwardToReplicas, + _callback + ); + return localVarCall; + } + + /** + * Clear all synonyms. Remove all synonyms from an index. + * + * @param indexName The index in which to perform the request. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return ClearAllSynonymsResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ClearAllSynonymsResponse clearAllSynonyms( + String indexName, + Boolean forwardToReplicas + ) throws ApiException { + ApiResponse localVarResp = clearAllSynonymsWithHttpInfo( + indexName, + forwardToReplicas + ); + return localVarResp.getData(); + } + + /** + * Clear all synonyms. Remove all synonyms from an index. + * + * @param indexName The index in which to perform the request. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return ApiResponse<ClearAllSynonymsResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse clearAllSynonymsWithHttpInfo( + String indexName, + Boolean forwardToReplicas + ) throws ApiException { + okhttp3.Call localVarCall = clearAllSynonymsValidateBeforeCall( + indexName, + forwardToReplicas, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Clear all synonyms. (asynchronously) Remove all synonyms from an index. + * + * @param indexName The index in which to perform the request. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call clearAllSynonymsAsync( + String indexName, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = clearAllSynonymsValidateBeforeCall( + indexName, + forwardToReplicas, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteIndex + * + * @param indexName The index in which to perform the request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call deleteIndexCall( + String indexName, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteIndexValidateBeforeCall( + String indexName, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling deleteIndex(Async)" + ); + } + + okhttp3.Call localVarCall = deleteIndexCall(indexName, _callback); + return localVarCall; + } + + /** + * Delete index. Delete an existing index. + * + * @param indexName The index in which to perform the request. (required) + * @return DeleteIndexResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public DeleteIndexResponse deleteIndex(String indexName) throws ApiException { + ApiResponse localVarResp = deleteIndexWithHttpInfo( + indexName + ); + return localVarResp.getData(); + } + + /** + * Delete index. Delete an existing index. + * + * @param indexName The index in which to perform the request. (required) + * @return ApiResponse<DeleteIndexResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse deleteIndexWithHttpInfo( + String indexName + ) throws ApiException { + okhttp3.Call localVarCall = deleteIndexValidateBeforeCall(indexName, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Delete index. (asynchronously) Delete an existing index. + * + * @param indexName The index in which to perform the request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call deleteIndexAsync( + String indexName, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = deleteIndexValidateBeforeCall( + indexName, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for deleteSynonym + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call deleteSynonymCall( + String indexName, + String objectID, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ) + .replaceAll( + "\\{" + "objectID" + "\\}", + this.escapeString(objectID.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (forwardToReplicas != null) { + localVarQueryParams.addAll( + this.parameterToPair("forwardToReplicas", forwardToReplicas) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "DELETE", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteSynonymValidateBeforeCall( + String indexName, + String objectID, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling deleteSynonym(Async)" + ); + } + + // verify the required parameter 'objectID' is set + if (objectID == null) { + throw new ApiException( + "Missing the required parameter 'objectID' when calling deleteSynonym(Async)" + ); + } + + okhttp3.Call localVarCall = deleteSynonymCall( + indexName, + objectID, + forwardToReplicas, + _callback + ); + return localVarCall; + } + + /** + * Delete synonym. Delete a single synonyms set, identified by the given objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return DeleteSynonymResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public DeleteSynonymResponse deleteSynonym( + String indexName, + String objectID, + Boolean forwardToReplicas + ) throws ApiException { + ApiResponse localVarResp = deleteSynonymWithHttpInfo( + indexName, + objectID, + forwardToReplicas + ); + return localVarResp.getData(); + } + + /** + * Delete synonym. Delete a single synonyms set, identified by the given objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return ApiResponse<DeleteSynonymResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse deleteSynonymWithHttpInfo( + String indexName, + String objectID, + Boolean forwardToReplicas + ) throws ApiException { + okhttp3.Call localVarCall = deleteSynonymValidateBeforeCall( + indexName, + objectID, + forwardToReplicas, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Delete synonym. (asynchronously) Delete a single synonyms set, identified by the given + * objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call deleteSynonymAsync( + String indexName, + String objectID, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = deleteSynonymValidateBeforeCall( + indexName, + objectID, + forwardToReplicas, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getSettings + * + * @param indexName The index in which to perform the request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call getSettingsCall( + String indexName, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/settings".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getSettingsValidateBeforeCall( + String indexName, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling getSettings(Async)" + ); + } + + okhttp3.Call localVarCall = getSettingsCall(indexName, _callback); + return localVarCall; + } + + /** + * Retrieve settings of a given indexName. + * + * @param indexName The index in which to perform the request. (required) + * @return IndexSettings + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public IndexSettings getSettings(String indexName) throws ApiException { + ApiResponse localVarResp = getSettingsWithHttpInfo( + indexName + ); + return localVarResp.getData(); + } + + /** + * Retrieve settings of a given indexName. + * + * @param indexName The index in which to perform the request. (required) + * @return ApiResponse<IndexSettings> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse getSettingsWithHttpInfo(String indexName) + throws ApiException { + okhttp3.Call localVarCall = getSettingsValidateBeforeCall(indexName, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Retrieve settings of a given indexName. + * + * @param indexName The index in which to perform the request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call getSettingsAsync( + String indexName, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = getSettingsValidateBeforeCall( + indexName, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for getSynonym + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call getSynonymCall( + String indexName, + String objectID, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ) + .replaceAll( + "\\{" + "objectID" + "\\}", + this.escapeString(objectID.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getSynonymValidateBeforeCall( + String indexName, + String objectID, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling getSynonym(Async)" + ); + } + + // verify the required parameter 'objectID' is set + if (objectID == null) { + throw new ApiException( + "Missing the required parameter 'objectID' when calling getSynonym(Async)" + ); + } + + okhttp3.Call localVarCall = getSynonymCall(indexName, objectID, _callback); + return localVarCall; + } + + /** + * Get synonym. Fetch a synonym object identified by its objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @return SynonymHit + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SynonymHit getSynonym(String indexName, String objectID) + throws ApiException { + ApiResponse localVarResp = getSynonymWithHttpInfo( + indexName, + objectID + ); + return localVarResp.getData(); + } + + /** + * Get synonym. Fetch a synonym object identified by its objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @return ApiResponse<SynonymHit> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse getSynonymWithHttpInfo( + String indexName, + String objectID + ) throws ApiException { + okhttp3.Call localVarCall = getSynonymValidateBeforeCall( + indexName, + objectID, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Get synonym. (asynchronously) Fetch a synonym object identified by its objectID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call getSynonymAsync( + String indexName, + String objectID, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = getSynonymValidateBeforeCall( + indexName, + objectID, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for listIndices + * + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call listIndicesCall( + Integer page, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/1/indexes"; + + 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(this.parameterToPair("Page", page)); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "GET", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listIndicesValidateBeforeCall( + Integer page, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = listIndicesCall(page, _callback); + return localVarCall; + } + + /** + * List existing indexes. List existing indexes from an application. + * + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional) + * @return ListIndicesResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ListIndicesResponse listIndices(Integer page) throws ApiException { + ApiResponse localVarResp = listIndicesWithHttpInfo( + page + ); + return localVarResp.getData(); + } + + /** + * List existing indexes. List existing indexes from an application. + * + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional) + * @return ApiResponse<ListIndicesResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse listIndicesWithHttpInfo(Integer page) + throws ApiException { + okhttp3.Call localVarCall = listIndicesValidateBeforeCall(page, null); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * List existing indexes. (asynchronously) List existing indexes from an application. + * + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call listIndicesAsync( + Integer page, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = listIndicesValidateBeforeCall(page, _callback); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for multipleQueries + * + * @param multipleQueriesObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call multipleQueriesCall( + MultipleQueriesObject multipleQueriesObject, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = multipleQueriesObject; + + // create path and map variables + String localVarPath = "/1/indexes/*/queries"; + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call multipleQueriesValidateBeforeCall( + MultipleQueriesObject multipleQueriesObject, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'multipleQueriesObject' is set + if (multipleQueriesObject == null) { + throw new ApiException( + "Missing the required parameter 'multipleQueriesObject' when calling" + + " multipleQueries(Async)" + ); + } + + okhttp3.Call localVarCall = multipleQueriesCall( + multipleQueriesObject, + _callback + ); + return localVarCall; + } + + /** + * Get search results for the given requests. + * + * @param multipleQueriesObject (required) + * @return MultipleQueriesResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public MultipleQueriesResponse multipleQueries( + MultipleQueriesObject multipleQueriesObject + ) throws ApiException { + ApiResponse localVarResp = multipleQueriesWithHttpInfo( + multipleQueriesObject + ); + return localVarResp.getData(); + } + + /** + * Get search results for the given requests. + * + * @param multipleQueriesObject (required) + * @return ApiResponse<MultipleQueriesResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse multipleQueriesWithHttpInfo( + MultipleQueriesObject multipleQueriesObject + ) throws ApiException { + okhttp3.Call localVarCall = multipleQueriesValidateBeforeCall( + multipleQueriesObject, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Get search results for the given requests. + * + * @param multipleQueriesObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call multipleQueriesAsync( + MultipleQueriesObject multipleQueriesObject, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = multipleQueriesValidateBeforeCall( + multipleQueriesObject, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for operationIndex + * + * @param indexName The index in which to perform the request. (required) + * @param operationIndexObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call operationIndexCall( + String indexName, + OperationIndexObject operationIndexObject, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = operationIndexObject; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/operation".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call operationIndexValidateBeforeCall( + String indexName, + OperationIndexObject operationIndexObject, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling operationIndex(Async)" + ); + } + + // verify the required parameter 'operationIndexObject' is set + if (operationIndexObject == null) { + throw new ApiException( + "Missing the required parameter 'operationIndexObject' when calling" + + " operationIndex(Async)" + ); + } + + okhttp3.Call localVarCall = operationIndexCall( + indexName, + operationIndexObject, + _callback + ); + return localVarCall; + } + + /** + * Copy/move index. Peforms a copy or a move operation on a index. + * + * @param indexName The index in which to perform the request. (required) + * @param operationIndexObject (required) + * @return OperationIndexResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public OperationIndexResponse operationIndex( + String indexName, + OperationIndexObject operationIndexObject + ) throws ApiException { + ApiResponse localVarResp = operationIndexWithHttpInfo( + indexName, + operationIndexObject + ); + return localVarResp.getData(); + } + + /** + * Copy/move index. Peforms a copy or a move operation on a index. + * + * @param indexName The index in which to perform the request. (required) + * @param operationIndexObject (required) + * @return ApiResponse<OperationIndexResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse operationIndexWithHttpInfo( + String indexName, + OperationIndexObject operationIndexObject + ) throws ApiException { + okhttp3.Call localVarCall = operationIndexValidateBeforeCall( + indexName, + operationIndexObject, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Copy/move index. (asynchronously) Peforms a copy or a move operation on a index. + * + * @param indexName The index in which to perform the request. (required) + * @param operationIndexObject (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call operationIndexAsync( + String indexName, + OperationIndexObject operationIndexObject, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = operationIndexValidateBeforeCall( + indexName, + operationIndexObject, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for saveObject + * + * @param indexName The index in which to perform the request. (required) + * @param requestBody The Algolia object. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveObjectCall( + String indexName, + Map requestBody, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = requestBody; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call saveObjectValidateBeforeCall( + String indexName, + Map requestBody, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling saveObject(Async)" + ); + } + + // verify the required parameter 'requestBody' is set + if (requestBody == null) { + throw new ApiException( + "Missing the required parameter 'requestBody' when calling saveObject(Async)" + ); + } + + okhttp3.Call localVarCall = saveObjectCall( + indexName, + requestBody, + _callback + ); + return localVarCall; + } + + /** + * Add an object to the index, automatically assigning it an object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param requestBody The Algolia object. (required) + * @return SaveObjectResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SaveObjectResponse saveObject( + String indexName, + Map requestBody + ) throws ApiException { + ApiResponse localVarResp = saveObjectWithHttpInfo( + indexName, + requestBody + ); + return localVarResp.getData(); + } + + /** + * Add an object to the index, automatically assigning it an object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param requestBody The Algolia object. (required) + * @return ApiResponse<SaveObjectResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse saveObjectWithHttpInfo( + String indexName, + Map requestBody + ) throws ApiException { + okhttp3.Call localVarCall = saveObjectValidateBeforeCall( + indexName, + requestBody, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Add an object to the index, automatically assigning it an object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param requestBody The Algolia object. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveObjectAsync( + String indexName, + Map requestBody, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = saveObjectValidateBeforeCall( + indexName, + requestBody, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for saveSynonym + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveSynonymCall( + String indexName, + String objectID, + SynonymHit synonymHit, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = synonymHit; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/{objectID}".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ) + .replaceAll( + "\\{" + "objectID" + "\\}", + this.escapeString(objectID.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (forwardToReplicas != null) { + localVarQueryParams.addAll( + this.parameterToPair("forwardToReplicas", forwardToReplicas) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call saveSynonymValidateBeforeCall( + String indexName, + String objectID, + SynonymHit synonymHit, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling saveSynonym(Async)" + ); + } + + // verify the required parameter 'objectID' is set + if (objectID == null) { + throw new ApiException( + "Missing the required parameter 'objectID' when calling saveSynonym(Async)" + ); + } + + // verify the required parameter 'synonymHit' is set + if (synonymHit == null) { + throw new ApiException( + "Missing the required parameter 'synonymHit' when calling saveSynonym(Async)" + ); + } + + okhttp3.Call localVarCall = saveSynonymCall( + indexName, + objectID, + synonymHit, + forwardToReplicas, + _callback + ); + return localVarCall; + } + + /** + * Save synonym. Create a new synonym object or update the existing synonym object with the given + * object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return SaveSynonymResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SaveSynonymResponse saveSynonym( + String indexName, + String objectID, + SynonymHit synonymHit, + Boolean forwardToReplicas + ) throws ApiException { + ApiResponse localVarResp = saveSynonymWithHttpInfo( + indexName, + objectID, + synonymHit, + forwardToReplicas + ); + return localVarResp.getData(); + } + + /** + * Save synonym. Create a new synonym object or update the existing synonym object with the given + * object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return ApiResponse<SaveSynonymResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse saveSynonymWithHttpInfo( + String indexName, + String objectID, + SynonymHit synonymHit, + Boolean forwardToReplicas + ) throws ApiException { + okhttp3.Call localVarCall = saveSynonymValidateBeforeCall( + indexName, + objectID, + synonymHit, + forwardToReplicas, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Save synonym. (asynchronously) Create a new synonym object or update the existing synonym + * object with the given object ID. + * + * @param indexName The index in which to perform the request. (required) + * @param objectID Unique identifier of an object. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveSynonymAsync( + String indexName, + String objectID, + SynonymHit synonymHit, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = saveSynonymValidateBeforeCall( + indexName, + objectID, + synonymHit, + forwardToReplicas, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for saveSynonyms + * + * @param indexName The index in which to perform the request. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @param replaceExistingSynonyms Replace all synonyms of the index with the ones sent with this + * request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveSynonymsCall( + String indexName, + List synonymHit, + Boolean forwardToReplicas, + Boolean replaceExistingSynonyms, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = synonymHit; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/batch".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (forwardToReplicas != null) { + localVarQueryParams.addAll( + this.parameterToPair("forwardToReplicas", forwardToReplicas) + ); + } + + if (replaceExistingSynonyms != null) { + localVarQueryParams.addAll( + this.parameterToPair("replaceExistingSynonyms", replaceExistingSynonyms) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call saveSynonymsValidateBeforeCall( + String indexName, + List synonymHit, + Boolean forwardToReplicas, + Boolean replaceExistingSynonyms, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling saveSynonyms(Async)" + ); + } + + // verify the required parameter 'synonymHit' is set + if (synonymHit == null) { + throw new ApiException( + "Missing the required parameter 'synonymHit' when calling saveSynonyms(Async)" + ); + } + + okhttp3.Call localVarCall = saveSynonymsCall( + indexName, + synonymHit, + forwardToReplicas, + replaceExistingSynonyms, + _callback + ); + return localVarCall; + } + + /** + * Save a batch of synonyms. Create/update multiple synonym objects at once, potentially replacing + * the entire list of synonyms if replaceExistingSynonyms is true. + * + * @param indexName The index in which to perform the request. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @param replaceExistingSynonyms Replace all synonyms of the index with the ones sent with this + * request. (optional) + * @return SaveSynonymsResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SaveSynonymsResponse saveSynonyms( + String indexName, + List synonymHit, + Boolean forwardToReplicas, + Boolean replaceExistingSynonyms + ) throws ApiException { + ApiResponse localVarResp = saveSynonymsWithHttpInfo( + indexName, + synonymHit, + forwardToReplicas, + replaceExistingSynonyms + ); + return localVarResp.getData(); + } + + /** + * Save a batch of synonyms. Create/update multiple synonym objects at once, potentially replacing + * the entire list of synonyms if replaceExistingSynonyms is true. + * + * @param indexName The index in which to perform the request. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @param replaceExistingSynonyms Replace all synonyms of the index with the ones sent with this + * request. (optional) + * @return ApiResponse<SaveSynonymsResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse saveSynonymsWithHttpInfo( + String indexName, + List synonymHit, + Boolean forwardToReplicas, + Boolean replaceExistingSynonyms + ) throws ApiException { + okhttp3.Call localVarCall = saveSynonymsValidateBeforeCall( + indexName, + synonymHit, + forwardToReplicas, + replaceExistingSynonyms, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Save a batch of synonyms. (asynchronously) Create/update multiple synonym objects at once, + * potentially replacing the entire list of synonyms if replaceExistingSynonyms is true. + * + * @param indexName The index in which to perform the request. (required) + * @param synonymHit (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @param replaceExistingSynonyms Replace all synonyms of the index with the ones sent with this + * request. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call saveSynonymsAsync( + String indexName, + List synonymHit, + Boolean forwardToReplicas, + Boolean replaceExistingSynonyms, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = saveSynonymsValidateBeforeCall( + indexName, + synonymHit, + forwardToReplicas, + replaceExistingSynonyms, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for search + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchCall( + String indexName, + SearchParams searchParams, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = searchParams; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/query".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call searchValidateBeforeCall( + String indexName, + SearchParams searchParams, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling search(Async)" + ); + } + + // verify the required parameter 'searchParams' is set + if (searchParams == null) { + throw new ApiException( + "Missing the required parameter 'searchParams' when calling search(Async)" + ); + } + + okhttp3.Call localVarCall = searchCall(indexName, searchParams, _callback); + return localVarCall; + } + + /** + * Get search results. + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (required) + * @return SearchResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SearchResponse search(String indexName, SearchParams searchParams) + throws ApiException { + ApiResponse localVarResp = searchWithHttpInfo( + indexName, + searchParams + ); + return localVarResp.getData(); + } + + /** + * Get search results. + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (required) + * @return ApiResponse<SearchResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse searchWithHttpInfo( + String indexName, + SearchParams searchParams + ) throws ApiException { + okhttp3.Call localVarCall = searchValidateBeforeCall( + indexName, + searchParams, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Get search results. + * + * @param indexName The index in which to perform the request. (required) + * @param searchParams (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchAsync( + String indexName, + SearchParams searchParams, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = searchValidateBeforeCall( + indexName, + searchParams, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for searchSynonyms + * + * @param indexName The index in which to perform the request. (required) + * @param query Search for specific synonyms matching this string. (optional, default to ) + * @param type Only search for specific types of synonyms. (optional) + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional, default to 0) + * @param hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchSynonymsCall( + String indexName, + String query, + String type, + Integer page, + Integer hitsPerPage, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/synonyms/search".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (query != null) { + localVarQueryParams.addAll(this.parameterToPair("query", query)); + } + + if (type != null) { + localVarQueryParams.addAll(this.parameterToPair("type", type)); + } + + if (page != null) { + localVarQueryParams.addAll(this.parameterToPair("Page", page)); + } + + if (hitsPerPage != null) { + localVarQueryParams.addAll( + this.parameterToPair("hitsPerPage", hitsPerPage) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = {}; + + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "POST", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call searchSynonymsValidateBeforeCall( + String indexName, + String query, + String type, + Integer page, + Integer hitsPerPage, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling searchSynonyms(Async)" + ); + } + + okhttp3.Call localVarCall = searchSynonymsCall( + indexName, + query, + type, + page, + hitsPerPage, + _callback + ); + return localVarCall; + } + + /** + * Get all synonyms that match a query. Search or browse all synonyms, optionally filtering them + * by type. + * + * @param indexName The index in which to perform the request. (required) + * @param query Search for specific synonyms matching this string. (optional, default to ) + * @param type Only search for specific types of synonyms. (optional) + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional, default to 0) + * @param hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) + * @return SearchSynonymsResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SearchSynonymsResponse searchSynonyms( + String indexName, + String query, + String type, + Integer page, + Integer hitsPerPage + ) throws ApiException { + ApiResponse localVarResp = searchSynonymsWithHttpInfo( + indexName, + query, + type, + page, + hitsPerPage + ); + return localVarResp.getData(); + } + + /** + * Get all synonyms that match a query. Search or browse all synonyms, optionally filtering them + * by type. + * + * @param indexName The index in which to perform the request. (required) + * @param query Search for specific synonyms matching this string. (optional, default to ) + * @param type Only search for specific types of synonyms. (optional) + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional, default to 0) + * @param hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) + * @return ApiResponse<SearchSynonymsResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse searchSynonymsWithHttpInfo( + String indexName, + String query, + String type, + Integer page, + Integer hitsPerPage + ) throws ApiException { + okhttp3.Call localVarCall = searchSynonymsValidateBeforeCall( + indexName, + query, + type, + page, + hitsPerPage, + null + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * Get all synonyms that match a query. (asynchronously) Search or browse all synonyms, optionally + * filtering them by type. + * + * @param indexName The index in which to perform the request. (required) + * @param query Search for specific synonyms matching this string. (optional, default to ) + * @param type Only search for specific types of synonyms. (optional) + * @param page Requested page (zero-based). When specified, will retrieve a specific page; the + * page size is implicitly set to 100. When null, will retrieve all indices (no pagination). + * (optional, default to 0) + * @param hitsPerPage Maximum number of objects to retrieve. (optional, default to 100) + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call searchSynonymsAsync( + String indexName, + String query, + String type, + Integer page, + Integer hitsPerPage, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = searchSynonymsValidateBeforeCall( + indexName, + query, + type, + page, + hitsPerPage, + _callback + ); + Type localVarReturnType = new TypeToken() {} + .getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + + /** + * Build call for setSettings + * + * @param indexName The index in which to perform the request. (required) + * @param indexSettings (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call setSettingsCall( + String indexName, + IndexSettings indexSettings, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + Object localVarPostBody = indexSettings; + + // create path and map variables + String localVarPath = + "/1/indexes/{indexName}/settings".replaceAll( + "\\{" + "indexName" + "\\}", + this.escapeString(indexName.toString()) + ); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (forwardToReplicas != null) { + localVarQueryParams.addAll( + this.parameterToPair("forwardToReplicas", forwardToReplicas) + ); + } + + final String[] localVarAccepts = { "application/json" }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { "application/json" }; + final String localVarContentType = + this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { "apiKey", "appId" }; + return this.buildCall( + localVarPath, + "PUT", + localVarQueryParams, + localVarCollectionQueryParams, + localVarPostBody, + localVarHeaderParams, + localVarCookieParams, + localVarFormParams, + localVarAuthNames, + _callback + ); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call setSettingsValidateBeforeCall( + String indexName, + IndexSettings indexSettings, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + // verify the required parameter 'indexName' is set + if (indexName == null) { + throw new ApiException( + "Missing the required parameter 'indexName' when calling setSettings(Async)" + ); + } + + // verify the required parameter 'indexSettings' is set + if (indexSettings == null) { + throw new ApiException( + "Missing the required parameter 'indexSettings' when calling setSettings(Async)" + ); + } + + okhttp3.Call localVarCall = setSettingsCall( + indexName, + indexSettings, + forwardToReplicas, + _callback + ); + return localVarCall; + } + + /** + * Update settings of a given indexName. Only specified settings are overridden; unspecified + * settings are left unchanged. Specifying null for a setting resets it to its default value. + * + * @param indexName The index in which to perform the request. (required) + * @param indexSettings (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return SetSettingsResponse + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public SetSettingsResponse setSettings( + String indexName, + IndexSettings indexSettings, + Boolean forwardToReplicas + ) throws ApiException { + ApiResponse localVarResp = setSettingsWithHttpInfo( + indexName, + indexSettings, + forwardToReplicas + ); + return localVarResp.getData(); + } + + /** + * Update settings of a given indexName. Only specified settings are overridden; unspecified + * settings are left unchanged. Specifying null for a setting resets it to its default value. + * + * @param indexName The index in which to perform the request. (required) + * @param indexSettings (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (optional) + * @return ApiResponse<SetSettingsResponse> + * @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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public ApiResponse setSettingsWithHttpInfo( + String indexName, + IndexSettings indexSettings, + Boolean forwardToReplicas + ) throws ApiException { + okhttp3.Call localVarCall = setSettingsValidateBeforeCall( + indexName, + indexSettings, + forwardToReplicas, + null + ); + Type localVarReturnType = new TypeToken() {}.getType(); + return this.execute(localVarCall, localVarReturnType); + } + + /** + * (asynchronously) Update settings of a given indexName. Only specified settings are overridden; + * unspecified settings are left unchanged. Specifying null for a setting resets it to its default + * value. + * + * @param indexName The index in which to perform the request. (required) + * @param indexSettings (required) + * @param forwardToReplicas When true, changes are also propagated to replicas of the given + * indexName. (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 OK -
400 Bad request or request arguments. -
402 This feature is not enabled on your Algolia account. -
403 Method not allowed with this API key. -
404 Index not found. -
+ */ + public okhttp3.Call setSettingsAsync( + String indexName, + IndexSettings indexSettings, + Boolean forwardToReplicas, + final ApiCallback _callback + ) throws ApiException { + okhttp3.Call localVarCall = setSettingsValidateBeforeCall( + indexName, + indexSettings, + forwardToReplicas, + _callback + ); + Type localVarReturnType = new TypeToken() {}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } +} diff --git a/clients/algoliasearch-client-java-2/pom.xml b/clients/algoliasearch-client-java-2/pom.xml new file mode 100644 index 00000000000..e905021f318 --- /dev/null +++ b/clients/algoliasearch-client-java-2/pom.xml @@ -0,0 +1,224 @@ + + 4.0.0 + com.algolia + algoliasearch-client-java-2 + jar + algoliasearch-client-java-2 + 0.1.0 + https://github.com/openapitools/openapi-generator + OpenAPI Java + + scm:git:git@github.com:openapitools/openapi-generator.git + scm:git:git@github.com:openapitools/openapi-generator.git + https://github.com/openapitools/openapi-generator + + + + + Unlicense + http://unlicense.org + repo + + + + + + OpenAPI-Generator Contributors + team@openapitools.org + OpenAPITools.org + http://openapitools.org + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + 128m + 512m + + -Xlint:all + -J-Xss4m + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + add_sources + generate-sources + + add-source + + + + algoliasearch-core + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.squareup.okhttp3 + okhttp + ${okhttp-version} + + + com.squareup.okhttp3 + logging-interceptor + ${okhttp-version} + + + com.google.code.gson + gson + ${gson-version} + + + io.gsonfire + gson-fire + ${gson-fire-version} + + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + + + 1.8 + ${java.version} + ${java.version} + 1.8.5 + 1.6.2 + 4.9.1 + 2.8.6 + 3.11 + 0.2.1 + 1.3.5 + UTF-8 + + diff --git a/openapitools.json b/openapitools.json index 860cd53e011..7f815657635 100644 --- a/openapitools.json +++ b/openapitools.json @@ -56,9 +56,29 @@ "npmName": "@algolia/client-personalization", "packageName": "@algolia/client-personalization", "npmVersion": "5.0.0", - "isPersonalizationHost": false } + }, + "java-search": { + "generatorName": "java", + "templateDir": "#{cwd}/templates/java/", + "config": "#{cwd}/openapitools.json", + "output": "#{cwd}/clients/algoliasearch-client-java-2", + "artifactId": "algoliasearch-client-java-2", + "groupId": "com.algolia", + "apiPackage": "com.algolia.search", + "invokerPackage": "com.algolia", + "modelPackage": "com.algolia.model", + "library": "okhttp-gson", + "glob": "specs/search/spec.yml", + "gitHost": "algolia", + "gitUserId": "algolia", + "gitRepoId": "algoliasearch-client-java-2", + "additionalProperties": { + "sourceFolder": "algoliasearch-core", + "java8": true, + "dateLibrary": "java8" + } } } } diff --git a/package.json b/package.json index 48f280b2327..4e5aa716142 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ ], "scripts": { "clean": "rm -rf **/dist **/build **/node_modules", + "client:build-java": "mvn clean install -f clients/algoliasearch-client-java-2/pom.xml", "client:build-js:personalization": "yarn workspace @algolia/client-personalization build", "client:build-js:recommend": "yarn workspace @algolia/recommend build", "client:build-js:search": "yarn workspace @algolia/client-search build", @@ -18,6 +19,7 @@ "lint": "eslint --ext=ts .", "post:generate": "./scripts/post-gen/global.sh", "generate": "./scripts/multiplexer.sh ./scripts/generate.sh ${0:-all} ${1:-all} && yarn post:generate", + "playground:java": "mvn clean compile exec:java -f playground/java/pom.xml", "playground:js:personalization": "yarn workspace javascript-playground start:personalization", "playground:js:recommend": "yarn workspace javascript-playground start:recommend", "playground:js:search": "yarn workspace javascript-playground start:search", @@ -40,6 +42,7 @@ "eslint-plugin-unused-imports": "2.0.0", "json": "11.0.0", "prettier": "2.5.0", + "prettier-plugin-java": "1.6.0", "swagger-cli": "4.0.4", "typescript": "4.5.2" }, diff --git a/playground/java/pom.xml b/playground/java/pom.xml new file mode 100644 index 00000000000..d8d5c582846 --- /dev/null +++ b/playground/java/pom.xml @@ -0,0 +1,89 @@ + + + + 4.0.0 + + com.test + java-playground + 1.0-SNAPSHOT + + java-playground + + + UTF-8 + 1.8 + 1.8 + + + + + junit + junit + 4.11 + test + + + io.github.cdimascio + dotenv-java + 2.2.0 + + + com.algolia + algoliasearch-client-java-2 + 0.1.0 + + + + + + + + maven-clean-plugin + 3.1.0 + + + + maven-resources-plugin + 3.0.2 + + + maven-compiler-plugin + 3.8.0 + + + maven-surefire-plugin + 2.22.1 + + + maven-jar-plugin + 3.0.2 + + + maven-install-plugin + 2.5.2 + + + maven-deploy-plugin + 2.8.2 + + + + maven-site-plugin + 3.7.1 + + + maven-project-info-reports-plugin + 3.0.0 + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + com.test.App + + + + + diff --git a/playground/java/src/main/java/com/test/App.java b/playground/java/src/main/java/com/test/App.java new file mode 100644 index 00000000000..cf1845ffb4d --- /dev/null +++ b/playground/java/src/main/java/com/test/App.java @@ -0,0 +1,28 @@ +package com.test; + +import com.algolia.model.*; +import com.algolia.search.SearchApi; +import com.algolia.ApiException; + +import io.github.cdimascio.dotenv.Dotenv; + +public class App { + public static void main(String[] args) { + Dotenv dotenv = Dotenv.configure().directory("../").load(); + System.out.println(dotenv.get("ALGOLIA_APPLICATION_ID")); + + SearchApi client = new SearchApi(dotenv.get("ALGOLIA_APPLICATION_ID"), dotenv.get("ALGOLIA_SEARCH_KEY")); + String indexName = "myIndexName"; // String | The index in which to perform the request. + SearchParams params = new SearchParams(); + try { + SearchResponse result = client.search(indexName, params); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling SearchApi#search"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} diff --git a/scripts/multiplexer.sh b/scripts/multiplexer.sh index 8d690d61d61..576f049e6c2 100755 --- a/scripts/multiplexer.sh +++ b/scripts/multiplexer.sh @@ -16,12 +16,14 @@ CLIENT=$3 LANGUAGES=() CLIENTS=() +GENERATORS=() + find_clients_and_languages() { echo "> Searching for available languages and clients..." - local generators=( $(cat openapitools.json | jq '."generator-cli".generators' | jq -r 'keys[]') ) + GENERATORS=( $(cat openapitools.json | jq '."generator-cli".generators' | jq -r 'keys[]') ) - for generator in "${generators[@]}"; do + for generator in "${GENERATORS[@]}"; do local lang=${generator%-*} local client=${generator#*-} @@ -57,6 +59,8 @@ fi for lang in "${LANGUAGE[@]}"; do for client in "${CLIENT[@]}"; do - $CMD $lang $client + if [[ " ${GENERATORS[*]} " =~ " ${lang}-${client} " ]]; then + $CMD $lang $client + fi done done diff --git a/scripts/post-gen/java.sh b/scripts/post-gen/java.sh new file mode 100755 index 00000000000..8b3bc1dbed1 --- /dev/null +++ b/scripts/post-gen/java.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +export GENERATOR=$1 +export CLIENT=$(cat openapitools.json | jq -r --arg generator "$GENERATOR" '."generator-cli".generators[$generator].output' | sed 's/#{cwd}\///g') + +# Restore the oneOf spec +mv ./specs/search/paths/search/search.yml.bak ./specs/search/paths/search/search.yml + +# Replace {} (Openapi default) with new Object +find $CLIENT -type f -name "*.java" | xargs sed -i '' -e 's/= {}/= new Object()/g' + +# Create a special class for the OneOf integer string (not complete yet, juste here for compilation) +echo "package com.algolia.model;public class OneOfintegerstring {}" > $CLIENT/algoliasearch-core/com/algolia/model/OneOfintegerstring.java + +# Download the formatter if not present and run it +javaFormatter="google-java-format-1.13.0-all-deps.jar" +if [[ ! -f "dist/$javaFormatter" ]]; then + echo "Downloading formatter dependency" + mkdir dist + curl -L "https://github.com/google/google-java-format/releases/download/v1.13.0/$javaFormatter" > dist/$javaFormatter +fi +find $CLIENT -type f -name "*.java" | xargs java -jar dist/$javaFormatter -r + +yarn prettier --write $CLIENT/**/*.java diff --git a/scripts/pre-gen/java.sh b/scripts/pre-gen/java.sh new file mode 100755 index 00000000000..778aa662a3b --- /dev/null +++ b/scripts/pre-gen/java.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +# Remove the oneOf in the spec until it's supported (https://github.com/OpenAPITools/openapi-generator/issues/10880). + +# Remove the oneOf and only keep the last $ref +perl -0777 -i.bak -pe "s/oneOf[\s\S]*- \$ref(?!.*- \$ref)//g" ./specs/search/paths/search/search.yml diff --git a/templates/java/CustomInstantDeserializer.mustache b/templates/java/CustomInstantDeserializer.mustache new file mode 100644 index 00000000000..5ebea810e1d --- /dev/null +++ b/templates/java/CustomInstantDeserializer.mustache @@ -0,0 +1,232 @@ +package {{invokerPackage}}; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonTokenId; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.JsonDeserializer; +import com.fasterxml.jackson.datatype.threetenbp.DecimalUtils; +import com.fasterxml.jackson.datatype.threetenbp.deser.ThreeTenDateTimeDeserializerBase; +import com.fasterxml.jackson.datatype.threetenbp.function.BiFunction; +import com.fasterxml.jackson.datatype.threetenbp.function.Function; +import org.threeten.bp.DateTimeException; +import org.threeten.bp.DateTimeUtils; +import org.threeten.bp.Instant; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.ZoneId; +import org.threeten.bp.ZonedDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.temporal.Temporal; +import org.threeten.bp.temporal.TemporalAccessor; + +import java.io.IOException; +import java.math.BigDecimal; + +/** + * Deserializer for ThreeTen temporal {@link Instant}s, {@link OffsetDateTime}, and {@link ZonedDateTime}s. + * Adapted from the jackson threetenbp InstantDeserializer to add support for deserializing rfc822 format. + * + * @author Nick Williams + */ +public class CustomInstantDeserializer + extends ThreeTenDateTimeDeserializerBase { + private static final long serialVersionUID = 1L; + + public static final CustomInstantDeserializer INSTANT = new CustomInstantDeserializer( + Instant.class, DateTimeFormatter.ISO_INSTANT, + new Function() { + @Override + public Instant apply(TemporalAccessor temporalAccessor) { + return Instant.from(temporalAccessor); + } + }, + new Function() { + @Override + public Instant apply(FromIntegerArguments a) { + return Instant.ofEpochMilli(a.value); + } + }, + new Function() { + @Override + public Instant apply(FromDecimalArguments a) { + return Instant.ofEpochSecond(a.integer, a.fraction); + } + }, + null + ); + + public static final CustomInstantDeserializer OFFSET_DATE_TIME = new CustomInstantDeserializer( + OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME, + new Function() { + @Override + public OffsetDateTime apply(TemporalAccessor temporalAccessor) { + return OffsetDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromIntegerArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public OffsetDateTime apply(FromDecimalArguments a) { + return OffsetDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public OffsetDateTime apply(OffsetDateTime d, ZoneId z) { + return d.withOffsetSameInstant(z.getRules().getOffset(d.toLocalDateTime())); + } + } + ); + + public static final CustomInstantDeserializer ZONED_DATE_TIME = new CustomInstantDeserializer( + ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME, + new Function() { + @Override + public ZonedDateTime apply(TemporalAccessor temporalAccessor) { + return ZonedDateTime.from(temporalAccessor); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromIntegerArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochMilli(a.value), a.zoneId); + } + }, + new Function() { + @Override + public ZonedDateTime apply(FromDecimalArguments a) { + return ZonedDateTime.ofInstant(Instant.ofEpochSecond(a.integer, a.fraction), a.zoneId); + } + }, + new BiFunction() { + @Override + public ZonedDateTime apply(ZonedDateTime zonedDateTime, ZoneId zoneId) { + return zonedDateTime.withZoneSameInstant(zoneId); + } + } + ); + + protected final Function fromMilliseconds; + + protected final Function fromNanoseconds; + + protected final Function parsedToValue; + + protected final BiFunction adjust; + + protected CustomInstantDeserializer(Class supportedType, + DateTimeFormatter parser, + Function parsedToValue, + Function fromMilliseconds, + Function fromNanoseconds, + BiFunction adjust) { + super(supportedType, parser); + this.parsedToValue = parsedToValue; + this.fromMilliseconds = fromMilliseconds; + this.fromNanoseconds = fromNanoseconds; + this.adjust = adjust == null ? new BiFunction() { + @Override + public T apply(T t, ZoneId zoneId) { + return t; + } + } : adjust; + } + + @SuppressWarnings("unchecked") + protected CustomInstantDeserializer(CustomInstantDeserializer base, DateTimeFormatter f) { + super((Class) base.handledType(), f); + parsedToValue = base.parsedToValue; + fromMilliseconds = base.fromMilliseconds; + fromNanoseconds = base.fromNanoseconds; + adjust = base.adjust; + } + + @Override + protected JsonDeserializer withDateFormat(DateTimeFormatter dtf) { + if (dtf == _formatter) { + return this; + } + return new CustomInstantDeserializer(this, dtf); + } + + @Override + public T deserialize(JsonParser parser, DeserializationContext context) throws IOException { + //NOTE: Timestamps contain no timezone info, and are always in configured TZ. Only + //string values have to be adjusted to the configured TZ. + switch (parser.getCurrentTokenId()) { + case JsonTokenId.ID_NUMBER_FLOAT: { + BigDecimal value = parser.getDecimalValue(); + long seconds = value.longValue(); + int nanoseconds = DecimalUtils.extractNanosecondDecimal(value, seconds); + return fromNanoseconds.apply(new FromDecimalArguments( + seconds, nanoseconds, getZone(context))); + } + + case JsonTokenId.ID_NUMBER_INT: { + long timestamp = parser.getLongValue(); + if (context.isEnabled(DeserializationFeature.READ_DATE_TIMESTAMPS_AS_NANOSECONDS)) { + return this.fromNanoseconds.apply(new FromDecimalArguments( + timestamp, 0, this.getZone(context) + )); + } + return this.fromMilliseconds.apply(new FromIntegerArguments( + timestamp, this.getZone(context) + )); + } + + case JsonTokenId.ID_STRING: { + String string = parser.getText().trim(); + if (string.length() == 0) { + return null; + } + if (string.endsWith("+0000")) { + string = string.substring(0, string.length() - 5) + "Z"; + } + T value; + try { + TemporalAccessor acc = _formatter.parse(string); + value = parsedToValue.apply(acc); + if (context.isEnabled(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE)) { + return adjust.apply(value, this.getZone(context)); + } + } catch (DateTimeException e) { + throw _peelDTE(e); + } + return value; + } + } + throw context.mappingException("Expected type float, integer, or string."); + } + + private ZoneId getZone(DeserializationContext context) { + // Instants are always in UTC, so don't waste compute cycles + return (_valueClass == Instant.class) ? null : DateTimeUtils.toZoneId(context.getTimeZone()); + } + + private static class FromIntegerArguments { + public final long value; + public final ZoneId zoneId; + + private FromIntegerArguments(long value, ZoneId zoneId) { + this.value = value; + this.zoneId = zoneId; + } + } + + private static class FromDecimalArguments { + public final long integer; + public final int fraction; + public final ZoneId zoneId; + + private FromDecimalArguments(long integer, int fraction, ZoneId zoneId) { + this.integer = integer; + this.fraction = fraction; + this.zoneId = zoneId; + } + } +} diff --git a/templates/java/JSON.mustache b/templates/java/JSON.mustache new file mode 100644 index 00000000000..cd412a98539 --- /dev/null +++ b/templates/java/JSON.mustache @@ -0,0 +1,537 @@ +package {{invokerPackage}}; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapter; +import com.google.gson.internal.bind.util.ISO8601Utils; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import com.google.gson.JsonElement; +import io.gsonfire.GsonFireBuilder; +import io.gsonfire.TypeSelector; +{{#joda}} +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormatter; +import org.joda.time.format.DateTimeFormatterBuilder; +import org.joda.time.format.ISODateTimeFormat; +{{/joda}} +{{#threetenbp}} +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; +{{/threetenbp}} + +{{#models.0}} +import {{modelPackage}}.*; +{{/models.0}} +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; +{{#java8}} +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +{{/java8}} +import java.util.Date; +import java.util.Locale; +import java.util.Map; +import java.util.HashMap; + +public class JSON { + private Gson gson; + private boolean isLenientOnJson = false; + private DateTypeAdapter dateTypeAdapter = new DateTypeAdapter(); + private SqlDateTypeAdapter sqlDateTypeAdapter = new SqlDateTypeAdapter(); + {{#joda}} + private DateTimeTypeAdapter dateTimeTypeAdapter = new DateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + {{/joda}} + {{#jsr310}} + private OffsetDateTimeTypeAdapter offsetDateTimeTypeAdapter = new OffsetDateTimeTypeAdapter(); + private LocalDateTypeAdapter localDateTypeAdapter = new LocalDateTypeAdapter(); + {{/jsr310}} + private ByteArrayAdapter byteArrayAdapter = new ByteArrayAdapter(); + + @SuppressWarnings("unchecked") + public static GsonBuilder createGson() { + GsonFireBuilder fireBuilder = new GsonFireBuilder() + {{#models}} + {{#model}} + {{#discriminator}} + .registerTypeSelector({{classname}}.class, new TypeSelector<{{classname}}>() { + @Override + public Class getClassForElement(JsonElement readElement) { + Map classByDiscriminatorValue = new HashMap(); + {{#mappedModels}} + classByDiscriminatorValue.put("{{mappingName}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{modelName}}.class); + {{/mappedModels}} + classByDiscriminatorValue.put("{{name}}"{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}, {{classname}}.class); + return getClassByDiscriminator(classByDiscriminatorValue, + getDiscriminatorValue(readElement, "{{{propertyBaseName}}}")); + } + }) + {{/discriminator}} + {{/model}} + {{/models}} + ; + GsonBuilder builder = fireBuilder.createGsonBuilder(); + {{#disableHtmlEscaping}} + builder.disableHtmlEscaping(); + {{/disableHtmlEscaping}} + 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{{^discriminatorCaseSensitive}}.toUpperCase(Locale.ROOT){{/discriminatorCaseSensitive}}); + if (null == clazz) { + throw new IllegalArgumentException("cannot determine model class of name: <" + discriminatorValue + ">"); + } + return clazz; + } + + public JSON() { + gson = createGson() + .registerTypeAdapter(Date.class, dateTypeAdapter) + .registerTypeAdapter(java.sql.Date.class, sqlDateTypeAdapter) + {{#joda}} + .registerTypeAdapter(DateTime.class, dateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + {{/joda}} + {{#jsr310}} + .registerTypeAdapter(OffsetDateTime.class, offsetDateTimeTypeAdapter) + .registerTypeAdapter(LocalDate.class, localDateTypeAdapter) + {{/jsr310}} + .registerTypeAdapter(byte[].class, byteArrayAdapter) + .create(); + } + + /** + * Get Gson. + * + * @return Gson + */ + public Gson getGson() { + return gson; + } + + /** + * Set Gson. + * + * @param gson Gson + * @return JSON + */ + public JSON setGson(Gson gson) { + this.gson = gson; + return this; + } + + public JSON setLenientOnJson(boolean lenientOnJson) { + isLenientOnJson = lenientOnJson; + return this; + } + + /** + * Serialize the given Java object into JSON string. + * + * @param obj Object + * @return String representation of the JSON + */ + public 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 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 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(); + } + } + } + + {{#joda}} + /** + * Gson TypeAdapter for Joda DateTime type + */ + public static class DateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public DateTimeTypeAdapter() { + this(new DateTimeFormatterBuilder() + .append(ISODateTimeFormat.dateTime().getPrinter(), ISODateTimeFormat.dateOptionalTimeParser().getParser()) + .toFormatter()); + } + + public DateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, DateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.print(date)); + } + } + + @Override + public DateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return formatter.parseDateTime(date); + } + } + } + + /** + * Gson TypeAdapter for Joda LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(ISODateTimeFormat.date()); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.print(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return formatter.parseLocalDate(date); + } + } + } + + public JSON setDateTimeFormat(DateTimeFormatter dateFormat) { + dateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + {{/joda}} + {{#jsr310}} + /** + * Gson TypeAdapter for JSR310 OffsetDateTime type + */ + public static class OffsetDateTimeTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public OffsetDateTimeTypeAdapter() { + this(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + + public OffsetDateTimeTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, OffsetDateTime date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public OffsetDateTime read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + if (date.endsWith("+0000")) { + date = date.substring(0, date.length()-5) + "Z"; + } + return OffsetDateTime.parse(date, formatter); + } + } + } + + /** + * Gson TypeAdapter for JSR310 LocalDate type + */ + public class LocalDateTypeAdapter extends TypeAdapter { + + private DateTimeFormatter formatter; + + public LocalDateTypeAdapter() { + this(DateTimeFormatter.ISO_LOCAL_DATE); + } + + public LocalDateTypeAdapter(DateTimeFormatter formatter) { + this.formatter = formatter; + } + + public void setFormat(DateTimeFormatter dateFormat) { + this.formatter = dateFormat; + } + + @Override + public void write(JsonWriter out, LocalDate date) throws IOException { + if (date == null) { + out.nullValue(); + } else { + out.value(formatter.format(date)); + } + } + + @Override + public LocalDate read(JsonReader in) throws IOException { + switch (in.peek()) { + case NULL: + in.nextNull(); + return null; + default: + String date = in.nextString(); + return LocalDate.parse(date, formatter); + } + } + } + + public JSON setOffsetDateTimeFormat(DateTimeFormatter dateFormat) { + offsetDateTimeTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setLocalDateFormat(DateTimeFormatter dateFormat) { + localDateTypeAdapter.setFormat(dateFormat); + return this; + } + + {{/jsr310}} + /** + * 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 JSON setDateFormat(DateFormat dateFormat) { + dateTypeAdapter.setFormat(dateFormat); + return this; + } + + public JSON setSqlDateFormat(DateFormat dateFormat) { + sqlDateTypeAdapter.setFormat(dateFormat); + return this; + } + +} diff --git a/templates/java/JavaTimeFormatter.mustache b/templates/java/JavaTimeFormatter.mustache new file mode 100644 index 00000000000..5850c6425e5 --- /dev/null +++ b/templates/java/JavaTimeFormatter.mustache @@ -0,0 +1,58 @@ +package {{invokerPackage}}; + +{{^threetenbp}} +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.time.format.DateTimeParseException; +{{/threetenbp}} +{{#threetenbp}} +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; +import org.threeten.bp.format.DateTimeParseException; +{{/threetenbp}} + +/** + * Class that add parsing/formatting support for Java 8+ {@code OffsetDateTime} class. + * It's generated for java clients when {@code AbstractJavaCodegen#dateLibrary} specified as {@code java8}. + */ +public class JavaTimeFormatter { + + private DateTimeFormatter offsetDateTimeFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME; + + /** + * Get the date format used to parse/format {@code OffsetDateTime} parameters. + * @return DateTimeFormatter + */ + public DateTimeFormatter getOffsetDateTimeFormatter() { + return offsetDateTimeFormatter; + } + + /** + * Set the date format used to parse/format {@code OffsetDateTime} parameters. + * @param offsetDateTimeFormatter {@code DateTimeFormatter} + */ + public void setOffsetDateTimeFormatter(DateTimeFormatter offsetDateTimeFormatter) { + this.offsetDateTimeFormatter = offsetDateTimeFormatter; + } + + /** + * Parse the given string into {@code OffsetDateTime} object. + * @param str String + * @return {@code OffsetDateTime} + */ + public OffsetDateTime parseOffsetDateTime(String str) { + try { + return OffsetDateTime.parse(str, offsetDateTimeFormatter); + } catch (DateTimeParseException e) { + throw new RuntimeException(e); + } + } + /** + * Format the given {@code OffsetDateTime} object into string. + * @param offsetDateTime {@code OffsetDateTime} + * @return {@code OffsetDateTime} in string format + */ + public String formatOffsetDateTime(OffsetDateTime offsetDateTime) { + return offsetDateTimeFormatter.format(offsetDateTime); + } +} diff --git a/templates/java/Pair.mustache b/templates/java/Pair.mustache new file mode 100644 index 00000000000..c79e1d28464 --- /dev/null +++ b/templates/java/Pair.mustache @@ -0,0 +1,47 @@ +package {{invokerPackage}}; + +public class Pair { + private String name = ""; + private String value = ""; + + public Pair (String name, String value) { + setName(name); + setValue(value); + } + + private void setName(String name) { + if (!isValidString(name)) { + return; + } + + this.name = name; + } + + private void setValue(String value) { + if (!isValidString(value)) { + return; + } + + this.value = value; + } + + public String getName() { + return this.name; + } + + public String getValue() { + return this.value; + } + + private boolean isValidString(String arg) { + if (arg == null) { + return false; + } + + if (arg.trim().isEmpty()) { + return false; + } + + return true; + } +} diff --git a/templates/java/ServerConfiguration.mustache b/templates/java/ServerConfiguration.mustache new file mode 100644 index 00000000000..e21b63391e2 --- /dev/null +++ b/templates/java/ServerConfiguration.mustache @@ -0,0 +1,58 @@ +package {{invokerPackage}}; + +import java.util.Map; + +/** + * 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 RuntimeException("The variable " + name + " in the server URL has invalid value " + value + "."); + } + } + url = url.replaceAll("\\{" + name + "\\}", value); + } + return url; + } + + /** + * Format URL template using default server variables. + * + * @return Formatted URL. + */ + public String URL() { + return URL(null); + } +} diff --git a/templates/java/ServerVariable.mustache b/templates/java/ServerVariable.mustache new file mode 100644 index 00000000000..1978b1eb95e --- /dev/null +++ b/templates/java/ServerVariable.mustache @@ -0,0 +1,23 @@ +package {{invokerPackage}}; + +import java.util.HashSet; + +/** + * Representing a Server Variable for server URL template substitution. + */ +public class ServerVariable { + public String description; + public String defaultValue; + public HashSet enumValues = null; + + /** + * @param description A description for the server variable. + * @param defaultValue The default value to use for substitution. + * @param enumValues An enumeration of string values to be used if the substitution options are from a limited set. + */ + public ServerVariable(String description, String defaultValue, HashSet enumValues) { + this.description = description; + this.defaultValue = defaultValue; + this.enumValues = enumValues; + } +} diff --git a/templates/java/StringUtil.mustache b/templates/java/StringUtil.mustache new file mode 100644 index 00000000000..4957c3b1c0a --- /dev/null +++ b/templates/java/StringUtil.mustache @@ -0,0 +1,69 @@ +package {{invokerPackage}}; + +import java.util.Collection; +import java.util.Iterator; + +public class StringUtil { + /** + * Check if the given array contains the given value (with case-insensitive comparison). + * + * @param array The array + * @param value The value to search + * @return true if the array contains the value + */ + public static boolean containsIgnoreCase(String[] array, String value) { + for (String str : array) { + if (value == null && str == null) { + return true; + } + if (value != null && value.equalsIgnoreCase(str)) { + return true; + } + } + return false; + } + + /** + * Join an array of strings with the given separator. + * + * Note: This might be replaced by utility method from commons-lang or guava someday + * if one of those libraries is added as dependency. + * + * + * @param array The array of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(String[] array, String separator) { + int len = array.length; + if (len == 0) { + return ""; + } + + StringBuilder out = new StringBuilder(); + out.append(array[0]); + for (int i = 1; i < len; i++) { + out.append(separator).append(array[i]); + } + return out.toString(); + } + + /** + * Join a list of strings with the given separator. + * + * @param list The list of strings + * @param separator The separator + * @return the resulting string + */ + public static String join(Collection list, String separator) { + Iterator iterator = list.iterator(); + StringBuilder out = new StringBuilder(); + if (iterator.hasNext()) { + out.append(iterator.next()); + } + while (iterator.hasNext()) { + out.append(separator).append(iterator.next()); + } + return out.toString(); + } +} diff --git a/templates/java/additionalEnumTypeAnnotations.mustache b/templates/java/additionalEnumTypeAnnotations.mustache new file mode 100644 index 00000000000..452340adc43 --- /dev/null +++ b/templates/java/additionalEnumTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalEnumTypeAnnotations}}{{{.}}} +{{/additionalEnumTypeAnnotations}} diff --git a/templates/java/additionalModelTypeAnnotations.mustache b/templates/java/additionalModelTypeAnnotations.mustache new file mode 100644 index 00000000000..a28cbba29ac --- /dev/null +++ b/templates/java/additionalModelTypeAnnotations.mustache @@ -0,0 +1,2 @@ +{{#additionalModelTypeAnnotations}}{{{.}}} +{{/additionalModelTypeAnnotations}} diff --git a/templates/java/enum_outer_doc.mustache b/templates/java/enum_outer_doc.mustache new file mode 100644 index 00000000000..20c512aaeae --- /dev/null +++ b/templates/java/enum_outer_doc.mustache @@ -0,0 +1,7 @@ +# {{classname}} + +## Enum + +{{#allowableValues}}{{#enumVars}} +* `{{name}}` (value: `{{{value}}}`) +{{/enumVars}}{{/allowableValues}} diff --git a/templates/java/gitignore.mustache b/templates/java/gitignore.mustache new file mode 100644 index 00000000000..7cf2ea329dc --- /dev/null +++ b/templates/java/gitignore.mustache @@ -0,0 +1,20 @@ +*.class + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +# build files +**/target +target +.gradle +build + +.openapi-generator diff --git a/templates/java/jackson_annotations.mustache b/templates/java/jackson_annotations.mustache new file mode 100644 index 00000000000..d7a36b1b94d --- /dev/null +++ b/templates/java/jackson_annotations.mustache @@ -0,0 +1,19 @@ +{{! + If this is map and items are nullable, make sure that nulls are included. + To determine what JsonInclude.Include method to use, consider the following: + * If the field is required, always include it, even if it is null. + * Else use custom behaviour, IOW use whatever is defined on the object mapper + }} + @JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}) + @JsonInclude({{#isMap}}{{#items.isNullable}}content = JsonInclude.Include.ALWAYS, {{/items.isNullable}}{{/isMap}}value = JsonInclude.Include.{{#required}}ALWAYS{{/required}}{{^required}}USE_DEFAULTS{{/required}}) + {{#withXml}} + {{^isContainer}} + @JacksonXmlProperty({{#isXmlAttribute}}isAttribute = true, {{/isXmlAttribute}}{{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/isContainer}} + {{#isContainer}} + {{#isXmlWrapped}} + // items.xmlName={{items.xmlName}} + @JacksonXmlElementWrapper(useWrapping = {{isXmlWrapped}}, {{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{#items.xmlName}}{{items.xmlName}}{{/items.xmlName}}{{^items.xmlName}}{{items.baseName}}{{/items.xmlName}}") + {{/isXmlWrapped}} + {{/isContainer}} + {{/withXml}} diff --git a/templates/java/libraries/okhttp-gson/ApiCallback.mustache b/templates/java/libraries/okhttp-gson/ApiCallback.mustache new file mode 100644 index 00000000000..a86035f690a --- /dev/null +++ b/templates/java/libraries/okhttp-gson/ApiCallback.mustache @@ -0,0 +1,49 @@ +package {{invokerPackage}}; + +import java.io.IOException; + +import java.util.Map; +import java.util.List; + +/** + * Callback for asynchronous API call. + * + * @param The return type + */ +public interface ApiCallback { + /** + * This is called when the API call fails. + * + * @param e The exception causing the failure + * @param statusCode Status code of the response if available, otherwise it would be 0 + * @param responseHeaders Headers of the response if available, otherwise it would be null + */ + void onFailure(ApiException e, int statusCode, Map> responseHeaders); + + /** + * This is called when the API call succeeded. + * + * @param result The result deserialized from response + * @param statusCode Status code of the response + * @param responseHeaders Headers of the response + */ + void onSuccess(T result, int statusCode, Map> responseHeaders); + + /** + * This is called when the API upload processing. + * + * @param bytesWritten bytes Written + * @param contentLength content length of request body + * @param done write end + */ + void onUploadProgress(long bytesWritten, long contentLength, boolean done); + + /** + * This is called when the API download processing. + * + * @param bytesRead bytes Read + * @param contentLength content length of the response + * @param done Read end + */ + void onDownloadProgress(long bytesRead, long contentLength, boolean done); +} diff --git a/templates/java/libraries/okhttp-gson/ApiClient.mustache b/templates/java/libraries/okhttp-gson/ApiClient.mustache new file mode 100644 index 00000000000..a06cbb1d706 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/ApiClient.mustache @@ -0,0 +1,1119 @@ +package {{invokerPackage}}; + +import okhttp3.*; +import okhttp3.internal.http.HttpMethod; +import okhttp3.internal.tls.OkHostnameVerifier; +import okhttp3.logging.HttpLoggingInterceptor; +import okhttp3.logging.HttpLoggingInterceptor.Level; +import okio.BufferedSink; +import okio.Okio; +{{#joda}} +import org.joda.time.DateTime; +import org.joda.time.LocalDate; +import org.joda.time.format.DateTimeFormatter; +{{/joda}} +{{#threetenbp}} +import org.threeten.bp.LocalDate; +import org.threeten.bp.OffsetDateTime; +import org.threeten.bp.format.DateTimeFormatter; +{{/threetenbp}} +{{#hasOAuthMethods}} +import org.apache.oltu.oauth2.client.request.OAuthClientRequest.TokenRequestBuilder; +import org.apache.oltu.oauth2.common.message.types.GrantType; +{{/hasOAuthMethods}} + +import javax.net.ssl.*; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.UnsupportedEncodingException; +import java.lang.reflect.Type; +import java.net.URI; +import java.net.URLConnection; +import java.net.URLEncoder; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.security.GeneralSecurityException; +import java.security.KeyStore; +import java.security.SecureRandom; +import java.security.cert.Certificate; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.text.DateFormat; +{{#java8}} +import java.time.LocalDate; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +{{/java8}} +import java.util.*; +import java.util.Map.Entry; +import java.util.concurrent.TimeUnit; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ApiClient { + + private boolean debugging = false; + private Map defaultHeaderMap = new HashMap(); + private Map defaultCookieMap = new HashMap(); + + private String basePath; + private String appId, apiKey; + + 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(String appId, String apiKey) { + init(); + initHttpClient(); + + this.basePath = "https://" + appId + "-1.algolianet.com"; + this.appId = appId; + this.apiKey = apiKey; + } + + 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); + } + {{#useGzipFeature}} + // Enable gzip request compression + builder.addInterceptor(new GzipRequestInterceptor()); + {{/useGzipFeature}} + + httpClient = builder.build(); + } + + private void init() { + verifyingSsl = true; + + json = new JSON(); + + // Set default User-Agent. + setUserAgent("{{{httpUserAgent}}}{{^httpUserAgent}}OpenAPI-Generator/{{{artifactVersion}}}/java{{/httpUserAgent}}"); + } + + /** + * 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; + } + + 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; + } + + public DateFormat getDateFormat() { + return dateFormat; + } + + public ApiClient setDateFormat(DateFormat dateFormat) { + this.json.setDateFormat(dateFormat); + return this; + } + + public ApiClient setSqlDateFormat(DateFormat dateFormat) { + this.json.setSqlDateFormat(dateFormat); + return this; + } + + public ApiClient setLenientOnJson(boolean lenientOnJson) { + this.json.setLenientOnJson(lenientOnJson); + return this; + } + + /** + * Set the User-Agent header's value (by adding to the default header map). + * + * @param userAgent HTTP request's user agent + * @return ApiClient + */ + public ApiClient setUserAgent(String userAgent) { + addDefaultHeader("User-Agent", userAgent); + return this; + } + + /** + * Add a default header. + * + * @param key The header's key + * @param value The header's value + * @return ApiClient + */ + public ApiClient addDefaultHeader(String key, String value) { + defaultHeaderMap.put(key, value); + return this; + } + + /** + * Add a default cookie. + * + * @param key The cookie's key + * @param value The cookie's value + * @return ApiClient + */ + public ApiClient addDefaultCookie(String key, String value) { + defaultCookieMap.put(key, value); + return this; + } + + /** + * Check that whether debugging is enabled for this API client. + * + * @return True if debugging is enabled, false otherwise. + */ + public boolean isDebugging() { + return debugging; + } + + /** + * Enable/disable debugging for this API client. + * + * @param debugging To enable (true) or disable (false) debugging + * @return ApiClient + */ + public ApiClient setDebugging(boolean debugging) { + if (debugging != this.debugging) { + if (debugging) { + loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(Level.BODY); + httpClient = httpClient.newBuilder().addInterceptor(loggingInterceptor).build(); + } else { + final OkHttpClient.Builder builder = httpClient.newBuilder(); + builder.interceptors().remove(loggingInterceptor); + httpClient = builder.build(); + loggingInterceptor = null; + } + } + this.debugging = debugging; + return this; + } + + /** + * 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 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 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 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 {{#joda}}|| param instanceof DateTime || param instanceof LocalDate{{/joda}}{{#jsr310}}|| param instanceof OffsetDateTime || param instanceof LocalDate{{/jsr310}}) { + //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(String.valueOf(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, + * or matches "any", JSON will be used. + */ + public String selectHeaderContentType(String[] contentTypes) { + if (contentTypes.length == 0 || 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 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); + } + } + + 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 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 (isJsonMime(contentType)) { + String content; + if (obj != null) { + content = json.serialize(obj); + } else { + content = null; + } + return RequestBody.create(content, MediaType.parse(contentType)); + } else { + throw new ApiException("Content type \"" + contentType + "\" is not supported"); + } + } + + /** + * {@link #execute(Call, Type)} + * + * @param Type + * @param call An instance of the Call object + * @return ApiResponse<T> + * @throws 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 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); + } + } + + {{#supportStreaming}} + public InputStream executeStream(Call call, Type returnType) throws ApiException { + try { + Response response = call.execute(); + if (!response.isSuccessful()) { + throw new ApiException(response.code(), response.message()); + } + if (response.body() == null) { + return null; + } + return response.body().byteStream(); + } catch (IOException e) { + throw new ApiException(e); + } + } + + {{/supportStreaming}} + /** + * {@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 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 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 ApiException If fail to serialize the request body object + */ + public Call buildCall(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(path, method, queryParams, collectionQueryParams, body, headerParams, cookieParams, formParams, authNames, callback); + + return httpClient.newCall(request); + } + + /** + * Build an HTTP request with the given options. + * + * @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 ApiException If fail to serialize the request body object + */ + public Request buildRequest(String path, String method, List queryParams, List collectionQueryParams, Object body, Map headerParams, Map cookieParams, Map formParams, String[] authNames, ApiCallback callback) throws ApiException { + updateParamsForAuth(authNames, queryParams, headerParams, cookieParams); + + final String url = buildUrl(path, queryParams, collectionQueryParams); + final Request.Builder reqBuilder = new Request.Builder().url(url); + processHeaderParams(headerParams, reqBuilder); + processCookieParams(cookieParams, reqBuilder); + + String contentType = (String) headerParams.get("Content-Type"); + // ensuring a default content type + if (contentType == null) { + contentType = "application/json"; + } + + RequestBody reqBody; + 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("", MediaType.parse(contentType)); + } + } else { + reqBody = serialize(body, contentType); + } + + // 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 path The sub path + * @param queryParams The query parameters + * @param collectionQueryParams The collection query parameters + * @return The full URL + */ + public String buildUrl(String path, List queryParams, List collectionQueryParams) { + final StringBuilder url = new StringBuilder(); + url.append(basePath).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 + */ + public void updateParamsForAuth(String[] authNames, List queryParams, Map headerParams, Map cookieParams) { + headerParams.put("X-Algolia-Application-Id", this.appId); + headerParams.put("X-Algolia-API-Key", this.apiKey); + } + + /** + * 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(); + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\"; filename=\"" + file.getName() + "\""); + MediaType mediaType = MediaType.parse(guessContentTypeFromFile(file)); + mpBuilder.addPart(partHeaders, RequestBody.create(file, mediaType)); + } else { + Headers partHeaders = Headers.of("Content-Disposition", "form-data; name=\"" + param.getKey() + "\""); + mpBuilder.addPart(partHeaders, RequestBody.create(parameterToString(param.getValue()), null)); + } + } + 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; + } + } + + /** + * 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" + Integer.toString(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); + } + } +} diff --git a/templates/java/libraries/okhttp-gson/ApiResponse.mustache b/templates/java/libraries/okhttp-gson/ApiResponse.mustache new file mode 100644 index 00000000000..0d2c7b1cd77 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/ApiResponse.mustache @@ -0,0 +1,56 @@ +package {{invokerPackage}}; + +import java.util.List; +import java.util.Map; +{{#caseInsensitiveResponseHeaders}} +import java.util.Map.Entry; +import java.util.TreeMap; +{{/caseInsensitiveResponseHeaders}} + +/** + * API response returned by API call. + * + * @param The type of data that is deserialized from response body + */ +public class ApiResponse { + final private int statusCode; + final private Map> headers; + final private T data; + + /** + * @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); + } + + /** + * @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; + {{#caseInsensitiveResponseHeaders}} + Map> responseHeaders = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + for(Entry> entry : headers.entrySet()){ + responseHeaders.put(entry.getKey().toLowerCase(), entry.getValue()); + } + {{/caseInsensitiveResponseHeaders}} + this.headers = {{#caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}}; + this.data = data; + } + + public int getStatusCode() { + return statusCode; + } + + public Map> getHeaders() { + return headers; + } + + public T getData() { + return data; + } +} diff --git a/templates/java/libraries/okhttp-gson/GzipRequestInterceptor.mustache b/templates/java/libraries/okhttp-gson/GzipRequestInterceptor.mustache new file mode 100644 index 00000000000..af802483cf0 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/GzipRequestInterceptor.mustache @@ -0,0 +1,72 @@ +package {{invokerPackage}}; + +import okhttp3.*; +import okio.Buffer; +import okio.BufferedSink; +import okio.GzipSink; +import okio.Okio; + +import java.io.IOException; + +/** + * Encodes request bodies using gzip. + * + * Taken from https://github.com/square/okhttp/issues/350 + */ +class GzipRequestInterceptor implements Interceptor { + @Override + public Response intercept(Chain chain) throws IOException { + Request originalRequest = chain.request(); + if (originalRequest.body() == null || originalRequest.header("Content-Encoding") != null) { + return chain.proceed(originalRequest); + } + + Request compressedRequest = originalRequest.newBuilder() + .header("Content-Encoding", "gzip") + .method(originalRequest.method(), forceContentLength(gzip(originalRequest.body()))) + .build(); + return chain.proceed(compressedRequest); + } + + private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { + final Buffer buffer = new Buffer(); + requestBody.writeTo(buffer); + return new RequestBody() { + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() { + return buffer.size(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + sink.write(buffer.snapshot()); + } + }; + } + + private RequestBody gzip(final RequestBody body) { + return new RequestBody() { + @Override + public MediaType contentType() { + return body.contentType(); + } + + @Override + public long contentLength() { + return -1; // We don't know the compressed length in advance! + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); + body.writeTo(gzipSink); + gzipSink.close(); + } + }; + } +} diff --git a/templates/java/libraries/okhttp-gson/ProgressRequestBody.mustache b/templates/java/libraries/okhttp-gson/ProgressRequestBody.mustache new file mode 100644 index 00000000000..b0ac8180e4d --- /dev/null +++ b/templates/java/libraries/okhttp-gson/ProgressRequestBody.mustache @@ -0,0 +1,60 @@ +package {{invokerPackage}}; + +import okhttp3.MediaType; +import okhttp3.RequestBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSink; +import okio.ForwardingSink; +import okio.Okio; +import okio.Sink; + +public class ProgressRequestBody extends RequestBody { + + private final RequestBody requestBody; + + private final ApiCallback callback; + + public ProgressRequestBody(RequestBody requestBody, ApiCallback callback) { + this.requestBody = requestBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return requestBody.contentType(); + } + + @Override + public long contentLength() throws IOException { + return requestBody.contentLength(); + } + + @Override + public void writeTo(BufferedSink sink) throws IOException { + BufferedSink bufferedSink = Okio.buffer(sink(sink)); + requestBody.writeTo(bufferedSink); + bufferedSink.flush(); + } + + private Sink sink(Sink sink) { + return new ForwardingSink(sink) { + + long bytesWritten = 0L; + long contentLength = 0L; + + @Override + public void write(Buffer source, long byteCount) throws IOException { + super.write(source, byteCount); + if (contentLength == 0) { + contentLength = contentLength(); + } + + bytesWritten += byteCount; + callback.onUploadProgress(bytesWritten, contentLength, bytesWritten == contentLength); + } + }; + } +} diff --git a/templates/java/libraries/okhttp-gson/ProgressResponseBody.mustache b/templates/java/libraries/okhttp-gson/ProgressResponseBody.mustache new file mode 100644 index 00000000000..2db7b351577 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/ProgressResponseBody.mustache @@ -0,0 +1,57 @@ +package {{invokerPackage}}; + +import okhttp3.MediaType; +import okhttp3.ResponseBody; + +import java.io.IOException; + +import okio.Buffer; +import okio.BufferedSource; +import okio.ForwardingSource; +import okio.Okio; +import okio.Source; + +public class ProgressResponseBody extends ResponseBody { + + private final ResponseBody responseBody; + private final ApiCallback callback; + private BufferedSource bufferedSource; + + public ProgressResponseBody(ResponseBody responseBody, ApiCallback callback) { + this.responseBody = responseBody; + this.callback = callback; + } + + @Override + public MediaType contentType() { + return responseBody.contentType(); + } + + @Override + public long contentLength() { + return responseBody.contentLength(); + } + + @Override + public BufferedSource source() { + if (bufferedSource == null) { + bufferedSource = Okio.buffer(source(responseBody.source())); + } + return bufferedSource; + } + + private Source source(Source source) { + return new ForwardingSource(source) { + long totalBytesRead = 0L; + + @Override + public long read(Buffer sink, long byteCount) throws IOException { + long bytesRead = super.read(sink, byteCount); + // read() returns the number of bytes read, or -1 if this source is exhausted. + totalBytesRead += bytesRead != -1 ? bytesRead : 0; + callback.onDownloadProgress(totalBytesRead, responseBody.contentLength(), bytesRead == -1); + return bytesRead; + } + }; + } +} diff --git a/templates/java/libraries/okhttp-gson/README.mustache b/templates/java/libraries/okhttp-gson/README.mustache new file mode 100644 index 00000000000..f3620a9cd33 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/README.mustache @@ -0,0 +1,72 @@ +# {{artifactId}} + +{{appName}} +- API version: {{appVersion}} + +{{{appDescriptionWithNewLines}}} +{{#infoUrl}} + + For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) +{{/infoUrl}} + +*Automatically generated by the [OpenAPI Generator](https://openapi-generator.tech)* + +## Requirements + +Building the API client library requires: +1. Java {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}}+ +2. Maven/Gradle + +## Installation + +To install the API client library to your local Maven repository, simply execute: + +```shell +mvn clean install +``` + +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: + +```shell +mvn clean deploy +``` + +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. + +### Maven users + +Add this dependency to your project's POM: + +```xml + + {{{groupId}}} + {{{artifactId}}} + {{{artifactVersion}}} + compile + +``` + +### Gradle users + +Add this dependency to your project's build file: + +```groovy +compile "{{{groupId}}}:{{{artifactId}}}:{{{artifactVersion}}}" +``` + +### Others + +At first generate the JAR by executing: + +```shell +mvn clean package +``` + +Then manually install the following JARs: + +* `target/{{{artifactId}}}-{{{artifactVersion}}}.jar` +* `target/lib/*.jar` + +## Getting Started + +Checkout the playground. diff --git a/templates/java/libraries/okhttp-gson/api.mustache b/templates/java/libraries/okhttp-gson/api.mustache new file mode 100644 index 00000000000..2b4931ee8eb --- /dev/null +++ b/templates/java/libraries/okhttp-gson/api.mustache @@ -0,0 +1,450 @@ +package {{package}}; + +import {{invokerPackage}}.ApiCallback; +import {{invokerPackage}}.ApiClient; +import {{invokerPackage}}.ApiException; +import {{invokerPackage}}.ApiResponse; +import {{invokerPackage}}.Pair; +import {{invokerPackage}}.ProgressRequestBody; +import {{invokerPackage}}.ProgressResponseBody; +{{#performBeanValidation}} +import {{invokerPackage}}.BeanValidationException; +{{/performBeanValidation}} + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + +{{#useBeanValidation}} +import javax.validation.constraints.*; +{{/useBeanValidation}} +{{#performBeanValidation}} +import javax.validation.ConstraintViolation; +import javax.validation.Validation; +import javax.validation.ValidatorFactory; +import javax.validation.executable.ExecutableValidator; +import java.util.Set; +import java.lang.reflect.Method; +import java.lang.reflect.Type; +{{/performBeanValidation}} + +{{#imports}}import {{import}}; +{{/imports}} + +import java.lang.reflect.Type; +{{^fullJavaUtil}} +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +{{#supportStreaming}} +import java.io.InputStream; +{{/supportStreaming}} +{{/fullJavaUtil}} + +{{#operations}} +public class {{classname}} extends ApiClient { + public {{classname}}(String appId, String apiKey) { + super(appId, apiKey); + } + + {{#operation}} + {{^vendorExtensions.x-group-parameters}}/** + * Build call for {{operationId}}{{#allParams}} + * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}} + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{{description}}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Call({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException { + Object localVarPostBody = {{#bodyParam}}{{paramName}}{{/bodyParam}}{{^bodyParam}}null{{/bodyParam}}; + + // create path and map variables + String localVarPath = "{{{path}}}"{{#pathParams}} + .replaceAll("\\{" + "{{baseName}}" + "\\}", this.escapeString({{#collectionFormat}}this.collectionPathParameterToString("{{{collectionFormat}}}", {{{paramName}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}.toString(){{/collectionFormat}})){{/pathParams}}; + + {{javaUtilPrefix}}List localVarQueryParams = new {{javaUtilPrefix}}ArrayList(); + {{javaUtilPrefix}}List localVarCollectionQueryParams = new {{javaUtilPrefix}}ArrayList(); + {{javaUtilPrefix}}Map localVarHeaderParams = new {{javaUtilPrefix}}HashMap(); + {{javaUtilPrefix}}Map localVarCookieParams = new {{javaUtilPrefix}}HashMap(); + {{javaUtilPrefix}}Map localVarFormParams = new {{javaUtilPrefix}}HashMap(); + + {{#formParams}} + if ({{paramName}} != null) { + localVarFormParams.put("{{baseName}}", {{paramName}}); + } + + {{/formParams}} + {{#queryParams}} + if ({{paramName}} != null) { + {{#collectionFormat}}localVarCollectionQueryParams.addAll(this.parameterToPairs("{{{.}}}", {{/collectionFormat}}{{^collectionFormat}}localVarQueryParams.addAll(this.parameterToPair({{/collectionFormat}}"{{baseName}}", {{paramName}})); + } + + {{/queryParams}} + {{#headerParams}} + if ({{paramName}} != null) { + localVarHeaderParams.put("{{baseName}}", this.parameterToString({{paramName}})); + } + + {{/headerParams}} + {{#cookieParams}} + if ({{paramName}} != null) { + localVarCookieParams.put("{{baseName}}", this.parameterToString({{paramName}})); + } + + {{/cookieParams}} + final String[] localVarAccepts = { + {{#produces}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/produces}} + }; + final String localVarAccept = this.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + {{#consumes}}"{{{mediaType}}}"{{^-last}}, {{/-last}}{{/consumes}} + }; + final String localVarContentType = this.selectHeaderContentType(localVarContentTypes); + localVarHeaderParams.put("Content-Type", localVarContentType); + + String[] localVarAuthNames = new String[] { {{#authMethods}}"{{name}}"{{^-last}}, {{/-last}}{{/authMethods}} }; + return this.buildCall(localVarPath, "{{httpMethod}}", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + @SuppressWarnings("rawtypes") + private okhttp3.Call {{operationId}}ValidateBeforeCall({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback _callback) throws ApiException { + {{^performBeanValidation}} + {{#allParams}}{{#required}} + // verify the required parameter '{{paramName}}' is set + if ({{paramName}} == null) { + throw new ApiException("Missing the required parameter '{{paramName}}' when calling {{operationId}}(Async)"); + } + {{/required}}{{/allParams}} + + okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); + return localVarCall; + + {{/performBeanValidation}} + {{#performBeanValidation}} + try { + ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + ExecutableValidator executableValidator = factory.getValidator().forExecutables(); + + Object[] parameterValues = { {{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}} }; + Method method = this.getClass().getMethod("{{operationId}}WithHttpInfo"{{#allParams}}, {{#isArray}}java.util.List{{/isArray}}{{#isMap}}java.util.Map{{/isMap}}{{^isArray}}{{^isMap}}{{{dataType}}}{{/isMap}}{{/isArray}}.class{{/allParams}}); + Set> violations = executableValidator.validateParameters(this, method, + parameterValues); + + if (violations.size() == 0) { + okhttp3.Call localVarCall = {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); + return localVarCall; + + } else { + throw new BeanValidationException((Set) violations); + } + } catch (NoSuchMethodException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } catch (SecurityException e) { + e.printStackTrace(); + throw new ApiException(e.getMessage()); + } + + {{/performBeanValidation}} + } + + {{^vendorExtensions.x-group-parameters}} + /** + * {{summary}} + * {{notes}}{{#allParams}} + * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}}{{#returnType}} + * @return {{.}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{{description}}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + {{#vendorExtensions.x-streaming}} + public {{#returnType}}InputStream {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + {{#returnType}}InputStream localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + return localVarResp;{{/returnType}} + } + {{/vendorExtensions.x-streaming}} + {{^vendorExtensions.x-streaming}} + public {{#returnType}}{{{.}}} {{/returnType}}{{^returnType}}void {{/returnType}}{{operationId}}({{#allParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + {{#returnType}}ApiResponse<{{{.}}}> localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + return localVarResp.getData();{{/returnType}} + } + {{/vendorExtensions.x-streaming}} + {{/vendorExtensions.x-group-parameters}} + + {{^vendorExtensions.x-group-parameters}}/** + * {{summary}} + * {{notes}}{{#allParams}} + * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}} + * @return ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{{description}}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-streaming}} InputStream {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null); + {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType(); + return this.executeStream(localVarCall, localVarReturnType);{{/returnType}} + } + {{/vendorExtensions.x-streaming}}{{^vendorExtensions.x-streaming}} ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Void{{/returnType}}> {{operationId}}WithHttpInfo({{#allParams}}{{#useBeanValidation}}{{>beanValidationQueryParams}}{{/useBeanValidation}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) throws ApiException { + okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}null); + {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType(); + return this.execute(localVarCall, localVarReturnType);{{/returnType}}{{^returnType}}return this.execute(localVarCall);{{/returnType}} + } + {{/vendorExtensions.x-streaming}} + + {{^vendorExtensions.x-group-parameters}}/** + * {{summary}} (asynchronously) + * {{notes}}{{#allParams}} + * @param {{paramName}} {{{description}}}{{#required}} (required){{/required}}{{^required}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}){{/required}}{{/allParams}} + * @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 + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{{description}}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public{{/vendorExtensions.x-group-parameters}}{{#vendorExtensions.x-group-parameters}}private{{/vendorExtensions.x-group-parameters}} okhttp3.Call {{operationId}}Async({{#allParams}}{{{dataType}}} {{paramName}}, {{/allParams}}final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> _callback) throws ApiException { + + okhttp3.Call localVarCall = {{operationId}}ValidateBeforeCall({{#allParams}}{{paramName}}, {{/allParams}}_callback); + {{#returnType}}Type localVarReturnType = new TypeToken<{{{returnType}}}>(){}.getType(); + this.executeAsync(localVarCall, localVarReturnType, _callback);{{/returnType}}{{^returnType}}this.executeAsync(localVarCall, _callback);{{/returnType}} + return localVarCall; + } + {{#vendorExtensions.x-group-parameters}} + + public class API{{operationId}}Request { + {{#requiredParams}} + private final {{{dataType}}} {{paramName}}; + {{/requiredParams}} + {{#optionalParams}} + private {{{dataType}}} {{paramName}}; + {{/optionalParams}} + + private API{{operationId}}Request({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) { + {{#requiredParams}} + this.{{paramName}} = {{paramName}}; + {{/requiredParams}} + } + + {{#optionalParams}} + /** + * Set {{paramName}} + * @param {{paramName}} {{{description}}} (optional{{^isContainer}}{{#defaultValue}}, default to {{.}}{{/defaultValue}}{{/isContainer}}) + * @return API{{operationId}}Request + */ + public API{{operationId}}Request {{paramName}}({{{dataType}}} {{paramName}}) { + this.{{paramName}} = {{paramName}}; + return this; + } + + {{/optionalParams}} + /** + * Build call for {{operationId}} + * @param _callback ApiCallback API callback + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException { + return {{operationId}}Call({{#allParams}}{{paramName}}, {{/allParams}}_callback); + } + + /** + * Execute {{operationId}} request{{#returnType}} + * @return {{.}}{{/returnType}} + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public {{{returnType}}}{{^returnType}}void{{/returnType}} execute() throws ApiException { + {{#returnType}}ApiResponse<{{{.}}}> localVarResp = {{/returnType}}{{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});{{#returnType}} + return localVarResp.getData();{{/returnType}} + } + + /** + * Execute {{operationId}} request with HTTP info returned + * @return ApiResponse<{{returnType}}{{^returnType}}Void{{/returnType}}> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public ApiResponse<{{{returnType}}}{{^returnType}}Void{{/returnType}}> executeWithHttpInfo() throws ApiException { + return {{operationId}}WithHttpInfo({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}); + } + + /** + * Execute {{operationId}} request (asynchronously) + * @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 + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public okhttp3.Call executeAsync(final ApiCallback<{{{returnType}}}{{^returnType}}Void{{/returnType}}> _callback) throws ApiException { + return {{operationId}}Async({{#allParams}}{{paramName}}, {{/allParams}}_callback); + } + } + + /** + * {{summary}} + * {{notes}}{{#requiredParams}} + * @param {{paramName}} {{{description}}} (required){{/requiredParams}} + * @return API{{operationId}}Request + {{#responses.0}} + * @http.response.details + + + {{#responses}} + + {{/responses}} +
Status Code Description Response Headers
{{code}} {{message}} {{#headers}} * {{baseName}} - {{{description}}}
{{/headers}}{{^headers.0}} - {{/headers.0}}
+ {{/responses.0}} + {{#isDeprecated}} + * @deprecated + {{/isDeprecated}} + {{#externalDocs}} + * {{{description}}} + * @see {{summary}} Documentation + {{/externalDocs}} + */ + {{#isDeprecated}} + @Deprecated + {{/isDeprecated}} + public API{{operationId}}Request {{operationId}}({{#requiredParams}}{{{dataType}}} {{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}) { + return new API{{operationId}}Request({{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}); + } + {{/vendorExtensions.x-group-parameters}} + {{/operation}} +} +{{/operations}} diff --git a/templates/java/libraries/okhttp-gson/apiException.mustache b/templates/java/libraries/okhttp-gson/apiException.mustache new file mode 100644 index 00000000000..f64a2f29ff7 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/apiException.mustache @@ -0,0 +1,93 @@ +package {{invokerPackage}}; + +import java.util.Map; +import java.util.List; +{{#caseInsensitiveResponseHeaders}} +import java.util.Map.Entry; +import java.util.TreeMap; +{{/caseInsensitiveResponseHeaders}} + +public class ApiException extends{{#useRuntimeException}} RuntimeException {{/useRuntimeException}}{{^useRuntimeException}} Exception {{/useRuntimeException}}{ + private int code = 0; + private Map> responseHeaders = null; + private String responseBody = null; + + public ApiException() {} + + public ApiException(Throwable throwable) { + super(throwable); + } + + public ApiException(String message) { + super(message); + } + + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders, String responseBody) { + super(message, throwable); + this.code = code; + {{#caseInsensitiveResponseHeaders}} + Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + for(Entry> entry : responseHeaders.entrySet()){ + headers.put(entry.getKey().toLowerCase(), entry.getValue()); + } + {{/caseInsensitiveResponseHeaders}} + this.responseHeaders = {{#caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}}; + this.responseBody = responseBody; + } + + public ApiException(String message, int code, Map> responseHeaders, String responseBody) { + this(message, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(String message, Throwable throwable, int code, Map> responseHeaders) { + this(message, throwable, code, responseHeaders, null); + } + + public ApiException(int code, Map> responseHeaders, String responseBody) { + this((String) null, (Throwable) null, code, responseHeaders, responseBody); + } + + public ApiException(int code, String message) { + super(message); + this.code = code; + } + + public ApiException(int code, String message, Map> responseHeaders, String responseBody) { + this(code, message); + {{#caseInsensitiveResponseHeaders}} + Map> headers = new TreeMap>(String.CASE_INSENSITIVE_ORDER); + for(Entry> entry : responseHeaders.entrySet()){ + headers.put(entry.getKey().toLowerCase(), entry.getValue()); + } + {{/caseInsensitiveResponseHeaders}} + this.responseHeaders = {{#caseInsensitiveResponseHeaders}}headers{{/caseInsensitiveResponseHeaders}}{{^caseInsensitiveResponseHeaders}}responseHeaders{{/caseInsensitiveResponseHeaders}}; + 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; + } +} diff --git a/templates/java/libraries/okhttp-gson/pom.mustache b/templates/java/libraries/okhttp-gson/pom.mustache new file mode 100644 index 00000000000..8482f4e4156 --- /dev/null +++ b/templates/java/libraries/okhttp-gson/pom.mustache @@ -0,0 +1,235 @@ + + 4.0.0 + {{groupId}} + {{artifactId}} + jar + {{artifactId}} + {{artifactVersion}} + {{artifactUrl}} + {{artifactDescription}} + + {{scmConnection}} + {{scmDeveloperConnection}} + {{scmUrl}} + +{{#parentOverridden}} + + {{{parentGroupId}}} + {{{parentArtifactId}}} + {{{parentVersion}}} + +{{/parentOverridden}} + + + + {{licenseName}} + {{licenseUrl}} + repo + + + + + + {{developerName}} + {{developerEmail}} + {{developerOrganization}} + {{developerOrganizationUrl}} + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.8.1 + + true + 128m + 512m + + -Xlint:all + -J-Xss4m + + + + + org.apache.maven.plugins + maven-enforcer-plugin + 3.0.0-M1 + + + enforce-maven + + enforce + + + + + 2.2.0 + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + + + loggerPath + conf/log4j.properties + + + -Xms512m -Xmx1500m + methods + 10 + + + + maven-dependency-plugin + + + package + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.2 + + + + jar + + + + + + + + + org.codehaus.mojo + build-helper-maven-plugin + 1.10 + + + add_sources + generate-sources + + add-source + + + + {{{sourceFolder}}} + + + + + + + + + + + sign-artifacts + + + + org.apache.maven.plugins + maven-gpg-plugin + 1.5 + + + sign-artifacts + verify + + sign + + + + + + + + + + + + io.swagger + swagger-annotations + ${swagger-core-version} + + + + com.google.code.findbugs + jsr305 + 3.0.2 + + + com.squareup.okhttp3 + okhttp + ${okhttp-version} + + + com.squareup.okhttp3 + logging-interceptor + ${okhttp-version} + + + com.google.code.gson + gson + ${gson-version} + + + io.gsonfire + gson-fire + ${gson-fire-version} + + + org.apache.commons + commons-lang3 + ${commons-lang3-version} + + + jakarta.annotation + jakarta.annotation-api + ${jakarta-annotation-version} + provided + + {{#openApiNullable}} + + org.openapitools + jackson-databind-nullable + ${jackson-databind-nullable-version} + + {{/openApiNullable}} + + + {{#java8}}1.8{{/java8}}{{^java8}}1.7{{/java8}} + ${java.version} + ${java.version} + 1.8.5 + 1.6.2 + 4.9.1 + 2.8.6 + 3.11 + {{#openApiNullable}} + 0.2.1 + {{/openApiNullable}} + 1.3.5 + UTF-8 + + diff --git a/templates/java/manifest.mustache b/templates/java/manifest.mustache new file mode 100644 index 00000000000..f44bd07d0a0 --- /dev/null +++ b/templates/java/manifest.mustache @@ -0,0 +1,3 @@ + + + diff --git a/templates/java/model.mustache b/templates/java/model.mustache new file mode 100644 index 00000000000..d8db05d71b8 --- /dev/null +++ b/templates/java/model.mustache @@ -0,0 +1,53 @@ +package {{package}}; + +{{#useReflectionEqualsHashCode}} +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +{{/useReflectionEqualsHashCode}} +import java.util.Objects; +import java.util.Arrays; +{{#imports}} +import {{import}}; +{{/imports}} +{{#serializableModel}} +import java.io.Serializable; +{{/serializableModel}} +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.annotation.JsonTypeName; +{{#withXml}} +import com.fasterxml.jackson.dataformat.xml.annotation.*; +{{/withXml}} +{{/jackson}} +{{#withXml}} +import javax.xml.bind.annotation.*; +{{/withXml}} +{{#jsonb}} +import java.lang.reflect.Type; +import javax.json.bind.annotation.JsonbTypeDeserializer; +import javax.json.bind.annotation.JsonbTypeSerializer; +import javax.json.bind.serializer.DeserializationContext; +import javax.json.bind.serializer.JsonbDeserializer; +import javax.json.bind.serializer.JsonbSerializer; +import javax.json.bind.serializer.SerializationContext; +import javax.json.stream.JsonGenerator; +import javax.json.stream.JsonParser; +import javax.json.bind.annotation.JsonbProperty; +{{/jsonb}} +{{#parcelableModel}} +import android.os.Parcelable; +import android.os.Parcel; +{{/parcelableModel}} +{{#useBeanValidation}} +import javax.validation.constraints.*; +import javax.validation.Valid; +{{/useBeanValidation}} +{{#performBeanValidation}} +import org.hibernate.validator.constraints.*; +{{/performBeanValidation}} + +{{#models}} +{{#model}} +{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{^isEnum}}{{#vendorExtensions.x-is-one-of-interface}}{{>oneof_interface}}{{/vendorExtensions.x-is-one-of-interface}}{{^vendorExtensions.x-is-one-of-interface}}{{>pojo}}{{/vendorExtensions.x-is-one-of-interface}}{{/isEnum}} +{{/model}} +{{/models}} diff --git a/templates/java/modelEnum.mustache b/templates/java/modelEnum.mustache new file mode 100644 index 00000000000..091bd1dd6bf --- /dev/null +++ b/templates/java/modelEnum.mustache @@ -0,0 +1,100 @@ +{{#jackson}} +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonValue; +{{/jackson}} +{{#gson}} +import java.io.IOException; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +{{/gson}} + +/** + * {{{description}}}{{^description}}Gets or Sets {{{name}}}{{/description}} + */ +{{#gson}} +@JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +{{#jsonb}} +@JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class) +@JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class) +{{/jsonb}} +{{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} { + {{#allowableValues}}{{#enumVars}} + {{#enumDescription}} + /** + * {{{.}}} + */ + {{/enumDescription}} + {{#withXml}} + @XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{/withXml}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}}{{/enumVars}}{{/allowableValues}} + + private {{{dataType}}} value; + + {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + +{{#jackson}} + @JsonValue +{{/jackson}} + public {{{dataType}}} getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +{{#jackson}} + @JsonCreator +{{/jackson}} + public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (b.value.equals(value)) { + return b; + } + } + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} + } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}next{{{dataType}}}(){{/isInteger}}{{/isNumber}}; + return {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}}); + } + } +{{/gson}} +{{#jsonb}} + public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> { + @Override + public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}} + } + } + + public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> { + @Override + public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } +{{/jsonb}} +} diff --git a/templates/java/modelInnerEnum.mustache b/templates/java/modelInnerEnum.mustache new file mode 100644 index 00000000000..3a829451278 --- /dev/null +++ b/templates/java/modelInnerEnum.mustache @@ -0,0 +1,95 @@ + /** + * {{{description}}}{{^description}}Gets or Sets {{{name}}}{{/description}} + */ +{{#gson}} + @JsonAdapter({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.Adapter.class) +{{/gson}} +{{#jsonb}} + @JsonbTypeSerializer({{datatypeWithEnum}}.Serializer.class) + @JsonbTypeDeserializer({{datatypeWithEnum}}.Deserializer.class) +{{/jsonb}} +{{#withXml}} + @XmlType(name="{{datatypeWithEnum}}") + @XmlEnum({{dataType}}.class) +{{/withXml}} + {{>additionalEnumTypeAnnotations}}public enum {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} { + {{#allowableValues}} + {{#enumVars}} + {{#enumDescription}} + /** + * {{{.}}} + */ + {{/enumDescription}} + {{#withXml}} + @XmlEnumValue({{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}{{{value}}}{{#isInteger}}"{{/isInteger}}{{#isDouble}}"{{/isDouble}}{{#isLong}}"{{/isLong}}{{#isFloat}}"{{/isFloat}}) + {{/withXml}} + {{{name}}}({{{value}}}){{^-last}}, + {{/-last}}{{#-last}};{{/-last}} + {{/enumVars}} + {{/allowableValues}} + + private {{{dataType}}} value; + + {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}({{{dataType}}} value) { + this.value = value; + } + +{{#jackson}} + @JsonValue +{{/jackson}} + public {{{dataType}}} getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + +{{#jackson}} + @JsonCreator +{{/jackson}} + public static {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (b.value.equals(value)) { + return b; + } + } + {{#isNullable}}return null;{{/isNullable}}{{^isNullable}}throw new IllegalArgumentException("Unexpected value '" + value + "'");{{/isNullable}} + } +{{#gson}} + + public static class Adapter extends TypeAdapter<{{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}> { + @Override + public void write(final JsonWriter jsonWriter, final {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException { + {{^isNumber}}{{{dataType}}}{{/isNumber}}{{#isNumber}}String{{/isNumber}} value = {{#isFloat}}(float){{/isFloat}} jsonReader.{{#isNumber}}nextString(){{/isNumber}}{{#isInteger}}nextInt(){{/isInteger}}{{^isNumber}}{{^isInteger}}{{#isFloat}}nextDouble{{/isFloat}}{{^isFloat}}next{{{dataType}}}{{/isFloat}}(){{/isInteger}}{{/isNumber}}; + return {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}}.fromValue({{#isNumber}}new BigDecimal({{/isNumber}}value{{#isNumber}}){{/isNumber}}); + } + } +{{/gson}} +{{#jsonb}} + public static final class Deserializer implements JsonbDeserializer<{{datatypeWithEnum}}> { + @Override + public {{datatypeWithEnum}} deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) { + for ({{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{{datatypeWithEnum}}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) { + if (String.valueOf(b.value).equals(parser.getString())) { + return b; + } + } + {{#useNullForUnknownEnumValue}}return null;{{/useNullForUnknownEnumValue}}{{^useNullForUnknownEnumValue}}throw new IllegalArgumentException("Unexpected value '" + parser.getString() + "'");{{/useNullForUnknownEnumValue}} + } + } + + public static final class Serializer implements JsonbSerializer<{{datatypeWithEnum}}> { + @Override + public void serialize({{datatypeWithEnum}} obj, JsonGenerator generator, SerializationContext ctx) { + generator.write(obj.value); + } + } +{{/jsonb}} + } diff --git a/templates/java/oneof_interface.mustache b/templates/java/oneof_interface.mustache new file mode 100644 index 00000000000..458dd3a0a36 --- /dev/null +++ b/templates/java/oneof_interface.mustache @@ -0,0 +1,6 @@ +{{>additionalModelTypeAnnotations}}{{>typeInfoAnnotation}}{{>xmlAnnotation}} +public interface {{classname}} {{#vendorExtensions.x-implements}}{{#-first}}extends {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{/vendorExtensions.x-implements}} { + {{#discriminator}} + public {{propertyType}} {{propertyGetter}}(); + {{/discriminator}} +} diff --git a/templates/java/openapi.mustache b/templates/java/openapi.mustache new file mode 100644 index 00000000000..34fbb53f331 --- /dev/null +++ b/templates/java/openapi.mustache @@ -0,0 +1 @@ +{{{openapi-yaml}}} diff --git a/templates/java/pojo.mustache b/templates/java/pojo.mustache new file mode 100644 index 00000000000..bd0d35b1377 --- /dev/null +++ b/templates/java/pojo.mustache @@ -0,0 +1,370 @@ +/** + * {{{description}}}{{^description}}{{classname}}{{/description}}{{#isDeprecated}} + * @deprecated{{/isDeprecated}} + */{{#isDeprecated}} +@Deprecated{{/isDeprecated}}{{#description}} +@ApiModel(description = "{{{.}}}"){{/description}} +{{#jackson}} +@JsonPropertyOrder({ +{{#vars}} + {{classname}}.JSON_PROPERTY_{{nameInSnakeCase}}{{^-last}},{{/-last}} +{{/vars}} +}) +@JsonTypeName("{{name}}") +{{/jackson}} +{{>additionalModelTypeAnnotations}}{{#discriminator}}{{>typeInfoAnnotation}}{{/discriminator}}{{>xmlAnnotation}} +public class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{{#vendorExtensions.x-implements}}{{#-first}}implements {{{.}}}{{/-first}}{{^-first}}, {{{.}}}{{/-first}}{{#-last}} {{/-last}}{{/vendorExtensions.x-implements}}{ +{{#serializableModel}} + private static final long serialVersionUID = 1L; + +{{/serializableModel}} + {{#vars}} + {{#isEnum}} + {{^isContainer}} +{{>modelInnerEnum}} + {{/isContainer}} + {{#isContainer}} + {{#mostInnerItems}} +{{>modelInnerEnum}} + {{/mostInnerItems}} + {{/isContainer}} + {{/isEnum}} + {{#gson}} + public static final String SERIALIZED_NAME_{{nameInSnakeCase}} = "{{baseName}}"; + {{/gson}} + {{#jackson}} + public static final String JSON_PROPERTY_{{nameInSnakeCase}} = "{{baseName}}"; + {{/jackson}} + {{#withXml}} + {{#isXmlAttribute}} + @XmlAttribute(name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/isXmlAttribute}} + {{^isXmlAttribute}} + {{^isContainer}} + @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/isContainer}} + {{#isContainer}} + // Is a container wrapped={{isXmlWrapped}} + {{#items}} + // items.name={{name}} items.baseName={{baseName}} items.xmlName={{xmlName}} items.xmlNamespace={{xmlNamespace}} + // items.example={{example}} items.type={{dataType}} + @XmlElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/items}} + {{#isXmlWrapped}} + @XmlElementWrapper({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{baseName}}{{/xmlName}}") + {{/isXmlWrapped}} + {{/isContainer}} + {{/isXmlAttribute}} + {{/withXml}} + {{#gson}} + @SerializedName(SERIALIZED_NAME_{{nameInSnakeCase}}) + {{/gson}} + {{#vendorExtensions.x-is-jackson-optional-nullable}} + {{#isContainer}} + private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>undefined(); + {{/isContainer}} + {{^isContainer}} + private JsonNullable<{{{datatypeWithEnum}}}> {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}}; + {{/isContainer}} + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + {{#isContainer}} + private {{{datatypeWithEnum}}} {{name}}{{#required}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}{{/required}}{{^required}} = null{{/required}}; + {{/isContainer}} + {{^isContainer}} + {{#isDiscriminator}}protected{{/isDiscriminator}}{{^isDiscriminator}}private{{/isDiscriminator}} {{{datatypeWithEnum}}} {{name}}{{#defaultValue}} = {{{.}}}{{/defaultValue}}; + {{/isContainer}} + {{/vendorExtensions.x-is-jackson-optional-nullable}} + + {{/vars}} + {{#parcelableModel}} + public {{classname}}() { + {{#parent}} + super(); + {{/parent}} + {{#gson}} + {{#discriminator}} + this.{{{discriminatorName}}} = this.getClass().getSimpleName(); + {{/discriminator}} + {{/gson}} + } + {{/parcelableModel}} + {{^parcelableModel}} + {{#gson}} + {{#discriminator}} + public {{classname}}() { + this.{{{discriminatorName}}} = this.getClass().getSimpleName(); + } + {{/discriminator}} + {{/gson}} + {{/parcelableModel}} + {{#vars}} + + {{^isReadOnly}} + public {{classname}} {{name}}({{{datatypeWithEnum}}} {{name}}) { + {{#vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}});{{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}}this.{{name}} = {{name}};{{/vendorExtensions.x-is-jackson-optional-nullable}} + return this; + } + {{#isArray}} + + public {{classname}} add{{nameInCamelCase}}Item({{{items.datatypeWithEnum}}} {{name}}Item) { + {{#vendorExtensions.x-is-jackson-optional-nullable}} + if (this.{{name}} == null || !this.{{name}}.isPresent()) { + this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}); + } + try { + this.{{name}}.get().add({{name}}Item); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + {{^required}} + if (this.{{name}} == null) { + this.{{name}} = {{{defaultValue}}}; + } + {{/required}} + this.{{name}}.add({{name}}Item); + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + } + {{/isArray}} + {{#isMap}} + + public {{classname}} put{{nameInCamelCase}}Item(String key, {{{items.datatypeWithEnum}}} {{name}}Item) { + {{#vendorExtensions.x-is-jackson-optional-nullable}} + if (this.{{name}} == null || !this.{{name}}.isPresent()) { + this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{{defaultValue}}}); + } + try { + this.{{name}}.get().put(key, {{name}}Item); + } catch (java.util.NoSuchElementException e) { + // this can never happen, as we make sure above that the value is present + } + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + {{^required}} + if (this.{{name}} == null) { + this.{{name}} = {{{defaultValue}}}; + } + {{/required}} + this.{{name}}.put(key, {{name}}Item); + return this; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + } + {{/isMap}} + + {{/isReadOnly}} + /** + {{#description}} + * {{{.}}} + {{/description}} + {{^description}} + * Get {{name}} + {{/description}} + {{#minimum}} + * minimum: {{.}} + {{/minimum}} + {{#maximum}} + * maximum: {{.}} + {{/maximum}} + * @return {{name}} + {{#deprecated}} + * @deprecated + {{/deprecated}} + **/ +{{#deprecated}} + @Deprecated +{{/deprecated}} +{{#required}} +{{#isNullable}} + @javax.annotation.Nullable +{{/isNullable}} +{{^isNullable}} + @javax.annotation.Nonnull +{{/isNullable}} +{{/required}} +{{^required}} + @javax.annotation.Nullable +{{/required}} +{{#jsonb}} + @JsonbProperty("{{baseName}}") +{{/jsonb}} +{{#useBeanValidation}}{{>beanValidation}}{{/useBeanValidation}} @ApiModelProperty({{#example}}example = "{{{.}}}", {{/example}}{{#required}}required = {{required}}, {{/required}}value = "{{{description}}}") +{{#vendorExtensions.x-extra-annotation}} + {{{vendorExtensions.x-extra-annotation}}} +{{/vendorExtensions.x-extra-annotation}} +{{#vendorExtensions.x-is-jackson-optional-nullable}} + {{!unannotated, Jackson would pick this up automatically and add it *in addition* to the _JsonNullable getter field}} + @JsonIgnore +{{/vendorExtensions.x-is-jackson-optional-nullable}} +{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#jackson}}{{> jackson_annotations}}{{/jackson}}{{/vendorExtensions.x-is-jackson-optional-nullable}} + public {{{datatypeWithEnum}}} {{getter}}() { + {{#vendorExtensions.x-is-jackson-optional-nullable}} + {{#isReadOnly}}{{! A readonly attribute doesn't have setter => jackson will set null directly if explicitly returned by API, so make sure we have an empty JsonNullable}} + if ({{name}} == null) { + {{name}} = JsonNullable.<{{{datatypeWithEnum}}}>{{#defaultValue}}of({{{.}}}){{/defaultValue}}{{^defaultValue}}undefined(){{/defaultValue}}; + } + {{/isReadOnly}} + return {{name}}.orElse(null); + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + return {{name}}; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + } + + {{#vendorExtensions.x-is-jackson-optional-nullable}} +{{> jackson_annotations}} + public JsonNullable<{{{datatypeWithEnum}}}> {{getter}}_JsonNullable() { + return {{name}}; + } + {{/vendorExtensions.x-is-jackson-optional-nullable}}{{#vendorExtensions.x-is-jackson-optional-nullable}} + @JsonProperty(JSON_PROPERTY_{{nameInSnakeCase}}) + {{#isReadOnly}}private{{/isReadOnly}}{{^isReadOnly}}public{{/isReadOnly}} void {{setter}}_JsonNullable(JsonNullable<{{{datatypeWithEnum}}}> {{name}}) { + {{! For getters/setters that have name differing from attribute name, we must include setter (albeit private) for jackson to be able to set the attribute}} + this.{{name}} = {{name}}; + } + {{/vendorExtensions.x-is-jackson-optional-nullable}} + + {{^isReadOnly}} +{{#jackson}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{> jackson_annotations}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{/jackson}} public void {{setter}}({{{datatypeWithEnum}}} {{name}}) { + {{#vendorExtensions.x-is-jackson-optional-nullable}} + this.{{name}} = JsonNullable.<{{{datatypeWithEnum}}}>of({{name}}); + {{/vendorExtensions.x-is-jackson-optional-nullable}} + {{^vendorExtensions.x-is-jackson-optional-nullable}} + this.{{name}} = {{name}}; + {{/vendorExtensions.x-is-jackson-optional-nullable}} + } + {{/isReadOnly}} + + {{/vars}} + + @Override + public boolean equals(Object o) { + {{#useReflectionEqualsHashCode}} + return EqualsBuilder.reflectionEquals(this, o, false, null, true); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + }{{#hasVars}} + {{classname}} {{classVarName}} = ({{classname}}) o; + return {{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}equalsNullable(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{#isByteArray}}Arrays{{/isByteArray}}{{^isByteArray}}Objects{{/isByteArray}}.equals(this.{{name}}, {{classVarName}}.{{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}} && + {{/-last}}{{/vars}}{{#parent}} && + super.equals(o){{/parent}};{{/hasVars}}{{^hasVars}} + return {{#parent}}super.equals(o){{/parent}}{{^parent}}true{{/parent}};{{/hasVars}} + {{/useReflectionEqualsHashCode}} + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static boolean equalsNullable(JsonNullable a, JsonNullable b) { + return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get())); + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} + + @Override + public int hashCode() { + {{#useReflectionEqualsHashCode}} + return HashCodeBuilder.reflectionHashCode(this); + {{/useReflectionEqualsHashCode}} + {{^useReflectionEqualsHashCode}} + return Objects.hash({{#vars}}{{#vendorExtensions.x-is-jackson-optional-nullable}}hashCodeNullable({{name}}){{/vendorExtensions.x-is-jackson-optional-nullable}}{{^vendorExtensions.x-is-jackson-optional-nullable}}{{^isByteArray}}{{name}}{{/isByteArray}}{{#isByteArray}}Arrays.hashCode({{name}}){{/isByteArray}}{{/vendorExtensions.x-is-jackson-optional-nullable}}{{^-last}}, {{/-last}}{{/vars}}{{#parent}}{{#hasVars}}, {{/hasVars}}super.hashCode(){{/parent}}); + {{/useReflectionEqualsHashCode}} + }{{#vendorExtensions.x-jackson-optional-nullable-helpers}} + + private static int hashCodeNullable(JsonNullable a) { + if (a == null) { + return 1; + } + return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31; + }{{/vendorExtensions.x-jackson-optional-nullable-helpers}} + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class {{classname}} {\n"); + {{#parent}} + sb.append(" ").append(toIndentedString(super.toString())).append("\n"); + {{/parent}} + {{#vars}} + sb.append(" {{name}}: ").append(toIndentedString({{name}})).append("\n"); + {{/vars}} + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private{{#jsonb}} static{{/jsonb}} String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + +{{#parcelableModel}} + + public void writeToParcel(Parcel out, int flags) { +{{#model}} +{{#isArray}} + out.writeList(this); +{{/isArray}} +{{^isArray}} +{{#parent}} + super.writeToParcel(out, flags); +{{/parent}} +{{#vars}} + out.writeValue({{name}}); +{{/vars}} +{{/isArray}} +{{/model}} + } + + {{classname}}(Parcel in) { +{{#isArray}} + in.readTypedList(this, {{arrayModelType}}.CREATOR); +{{/isArray}} +{{^isArray}} +{{#parent}} + super(in); +{{/parent}} +{{#vars}} +{{#isPrimitiveType}} + {{name}} = ({{{datatypeWithEnum}}})in.readValue(null); +{{/isPrimitiveType}} +{{^isPrimitiveType}} + {{name}} = ({{{datatypeWithEnum}}})in.readValue({{complexType}}.class.getClassLoader()); +{{/isPrimitiveType}} +{{/vars}} +{{/isArray}} + } + + public int describeContents() { + return 0; + } + + public static final Parcelable.Creator<{{classname}}> CREATOR = new Parcelable.Creator<{{classname}}>() { + public {{classname}} createFromParcel(Parcel in) { +{{#model}} +{{#isArray}} + {{classname}} result = new {{classname}}(); + result.addAll(in.readArrayList({{arrayModelType}}.class.getClassLoader())); + return result; +{{/isArray}} +{{^isArray}} + return new {{classname}}(in); +{{/isArray}} +{{/model}} + } + public {{classname}}[] newArray(int size) { + return new {{classname}}[size]; + } + }; +{{/parcelableModel}} +} diff --git a/templates/java/typeInfoAnnotation.mustache b/templates/java/typeInfoAnnotation.mustache new file mode 100644 index 00000000000..63eb42ea500 --- /dev/null +++ b/templates/java/typeInfoAnnotation.mustache @@ -0,0 +1,16 @@ +{{#jackson}} + +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true) +{{#discriminator.mappedModels}} +{{#-first}} +@JsonSubTypes({ +{{/-first}} + @JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"), +{{#-last}} +}) +{{/-last}} +{{/discriminator.mappedModels}} +{{#isClassnameSanitized}} +@JsonTypeName("{{name}}") +{{/isClassnameSanitized}} +{{/jackson}} diff --git a/templates/java/xmlAnnotation.mustache b/templates/java/xmlAnnotation.mustache new file mode 100644 index 00000000000..af6aaa50fbb --- /dev/null +++ b/templates/java/xmlAnnotation.mustache @@ -0,0 +1,6 @@ +{{#withXml}} + +@XmlRootElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}name = "{{xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}") +@XmlAccessorType(XmlAccessType.FIELD) +{{#jackson}} +@JacksonXmlRootElement({{#xmlNamespace}}namespace="{{.}}", {{/xmlNamespace}}localName = "{{xmlName}}{{^xmlName}}{{classname}}{{/xmlName}}"){{/jackson}}{{/withXml}} diff --git a/templates/javascript/api-single.mustache b/templates/javascript/api-single.mustache index 05cf6a95e10..f1bd91b08f8 100644 --- a/templates/javascript/api-single.mustache +++ b/templates/javascript/api-single.mustache @@ -120,7 +120,7 @@ export class {{classname}} { * @summary {{&summary}} {{/summary}} {{#allParams}} - * @param {{paramName}} {{^description}}The {{paramName}}{{/description}}{{#description}}{{description}}{{/description}} + * @param {{paramName}} {{^description}}The {{paramName}}{{/description}}{{#description}}{{{description}}}{{/description}} {{/allParams}} */ public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}) : Promise<{{{returnType}}}> { diff --git a/templates/javascript/licenseInfo.mustache b/templates/javascript/licenseInfo.mustache deleted file mode 100644 index 9866f297a4d..00000000000 --- a/templates/javascript/licenseInfo.mustache +++ /dev/null @@ -1,11 +0,0 @@ -/** - * {{{appName}}} - * {{{appDescription}}} - * - * {{#version}}The version of the OpenAPI document: {{{version}}}{{/version}} - * {{#infoEmail}}Contact: {{{infoEmail}}}{{/infoEmail}} - * - * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). - * https://openapi-generator.tech - * Do not edit the class manually. - */ diff --git a/yarn.lock b/yarn.lock index e14bbac32d3..bee0a50aaa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -24,6 +24,7 @@ __metadata: eslint-plugin-unused-imports: 2.0.0 json: 11.0.0 prettier: 2.5.0 + prettier-plugin-java: 1.6.0 swagger-cli: 4.0.4 typescript: 4.5.2 languageName: unknown @@ -1802,6 +1803,15 @@ __metadata: languageName: node linkType: hard +"chevrotain@npm:6.5.0": + version: 6.5.0 + resolution: "chevrotain@npm:6.5.0" + dependencies: + regexp-to-ast: 0.4.0 + checksum: ce03cf3874ae1fd91bb57de753ea313442c7d1be04f59ab126c237062b51f5cb3204e9bdbb1b469973c96c1ce0850e83f909bee14a23bb88a0dbbd964e1c2a9e + languageName: node + linkType: hard + "chownr@npm:^2.0.0": version: 2.0.0 resolution: "chownr@npm:2.0.0" @@ -3636,6 +3646,16 @@ fsevents@^2.3.2: languageName: node linkType: hard +"java-parser@npm:2.0.0": + version: 2.0.0 + resolution: "java-parser@npm:2.0.0" + dependencies: + chevrotain: 6.5.0 + lodash: 4.17.21 + checksum: ac2ccd448d0b5d9232927f514279edd1557cd898455d6528190ae2568303d73f53214c2977f6988d1c5c351719c69dd82c65850ba53d77d0cf0449e5b42cbe81 + languageName: node + linkType: hard + "javascript-playground@workspace:playground/javascript": version: 0.0.0-use.local resolution: "javascript-playground@workspace:playground/javascript" @@ -5041,6 +5061,26 @@ fsevents@^2.3.2: languageName: node linkType: hard +"prettier-plugin-java@npm:1.6.0": + version: 1.6.0 + resolution: "prettier-plugin-java@npm:1.6.0" + dependencies: + java-parser: 2.0.0 + lodash: 4.17.21 + prettier: 2.3.1 + checksum: 30fe055ba370cd9f05204ea5b5cabdb490521b84d7673ded0151aba16c0767b1f596600a4924b3541ac1a82819b67a5cd783094b53192612e9f48ae23edbaa3d + languageName: node + linkType: hard + +"prettier@npm:2.3.1": + version: 2.3.1 + resolution: "prettier@npm:2.3.1" + bin: + prettier: bin-prettier.js + checksum: 3b37731ff7150feecf19736c77c790e7e276b404ac9af81cbaf87cfecefc48ef9a864f34c2a5caf5955378b8f2525984b8611703a0d9c1f052b4cfa6eb35899f + languageName: node + linkType: hard + "prettier@npm:2.5.0": version: 2.5.0 resolution: "prettier@npm:2.5.0" @@ -5142,6 +5182,13 @@ fsevents@^2.3.2: languageName: node linkType: hard +"regexp-to-ast@npm:0.4.0": + version: 0.4.0 + resolution: "regexp-to-ast@npm:0.4.0" + checksum: 0f42d802b6259dcd442f79460d8764aa39165323098a6346aded67957816eb2d007ab09e6c674448425df8f721692258c87b51b1ce75c5df23b390dbb36056c0 + languageName: node + linkType: hard + "regexpp@npm:^3.2.0": version: 3.2.0 resolution: "regexpp@npm:3.2.0"