Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
// - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
package com.algolia.api;
import com.algolia.ApiClient;
import com.algolia.config.*;
import com.algolia.config.ClientOptions;
import com.algolia.exceptions.*;
import com.algolia.model.recommend.*;
import com.algolia.utils.*;
import com.fasterxml.jackson.core.type.TypeReference;
import java.time.Duration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nonnull;
public class RecommendClient extends ApiClient {
public RecommendClient(String appId, String apiKey) {
this(appId, apiKey, null);
}
public RecommendClient(String appId, String apiKey, ClientOptions options) {
super(
appId,
apiKey,
"Recommend",
options,
getDefaultHosts(appId),
Duration.ofMillis(2000L),
Duration.ofMillis(5000L),
Duration.ofMillis(30000L)
);
}
private static List getDefaultHosts(String appId) {
List hosts = new ArrayList<>();
hosts.add(new Host(appId + "-dsn.algolia.net", EnumSet.of(CallType.READ)));
hosts.add(new Host(appId + ".algolia.net", EnumSet.of(CallType.WRITE)));
List commonHosts = new ArrayList<>();
commonHosts.add(new Host(appId + "-1.algolianet.com", EnumSet.of(CallType.READ, CallType.WRITE)));
commonHosts.add(new Host(appId + "-2.algolianet.com", EnumSet.of(CallType.READ, CallType.WRITE)));
commonHosts.add(new Host(appId + "-3.algolianet.com", EnumSet.of(CallType.READ, CallType.WRITE)));
Collections.shuffle(commonHosts, new Random());
return Stream.concat(hosts.stream(), commonHosts.stream()).collect(Collectors.toList());
}
/**
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param recommendRule (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public RecommendUpdatedAtResponse batchRecommendRules(
@Nonnull String indexName,
@Nonnull RecommendModels model,
List recommendRule,
RequestOptions requestOptions
) throws AlgoliaRuntimeException {
return LaunderThrowable.await(batchRecommendRulesAsync(indexName, model, recommendRule, requestOptions));
}
/**
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param recommendRule (optional)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public RecommendUpdatedAtResponse batchRecommendRules(
@Nonnull String indexName,
@Nonnull RecommendModels model,
List recommendRule
) throws AlgoliaRuntimeException {
return this.batchRecommendRules(indexName, model, recommendRule, null);
}
/**
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public RecommendUpdatedAtResponse batchRecommendRules(
@Nonnull String indexName,
@Nonnull RecommendModels model,
RequestOptions requestOptions
) throws AlgoliaRuntimeException {
return this.batchRecommendRules(indexName, model, null, requestOptions);
}
/**
* Create or update a batch of Recommend Rules Each Recommend Rule is created or updated,
* depending on whether a Recommend Rule with the same `objectID` already exists. You may also
* specify `true` for `clearExistingRules`, in which case the batch will atomically replace all
* the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public RecommendUpdatedAtResponse batchRecommendRules(@Nonnull String indexName, @Nonnull RecommendModels model)
throws AlgoliaRuntimeException {
return this.batchRecommendRules(indexName, model, null, null);
}
/**
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param recommendRule (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public CompletableFuture batchRecommendRulesAsync(
@Nonnull String indexName,
@Nonnull RecommendModels model,
List recommendRule,
RequestOptions requestOptions
) throws AlgoliaRuntimeException {
Parameters.requireNonNull(indexName, "Parameter `indexName` is required when calling `batchRecommendRules`.");
Parameters.requireNonNull(model, "Parameter `model` is required when calling `batchRecommendRules`.");
HttpRequest request = HttpRequest.builder()
.setPath("/1/indexes/{indexName}/{model}/recommend/rules/batch", indexName, model)
.setMethod("POST")
.setBody(recommendRule)
.build();
return executeAsync(request, requestOptions, new TypeReference() {});
}
/**
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param recommendRule (optional)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public CompletableFuture batchRecommendRulesAsync(
@Nonnull String indexName,
@Nonnull RecommendModels model,
List recommendRule
) throws AlgoliaRuntimeException {
return this.batchRecommendRulesAsync(indexName, model, recommendRule, null);
}
/**
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public CompletableFuture batchRecommendRulesAsync(
@Nonnull String indexName,
@Nonnull RecommendModels model,
RequestOptions requestOptions
) throws AlgoliaRuntimeException {
return this.batchRecommendRulesAsync(indexName, model, null, requestOptions);
}
/**
* (asynchronously) Create or update a batch of Recommend Rules Each Recommend Rule is created or
* updated, depending on whether a Recommend Rule with the same `objectID` already exists. You may
* also specify `true` for `clearExistingRules`, in which case the batch will atomically replace
* all the existing Recommend Rules. Recommend Rules are similar to Search Rules, except that the
* conditions and consequences apply to a [source
* item](/doc/guides/algolia-recommend/overview/#recommend-models) instead of a query. The main
* differences are the following: - Conditions `pattern` and `anchoring` are unavailable. -
* Condition `filters` triggers if the source item matches the specified filters. - Condition
* `filters` accepts numeric filters. - Consequence `params` only covers filtering parameters. -
* Consequence `automaticFacetFilters` doesn't require a facet value placeholder (it tries to
* match the data source item's attributes instead).
*
* @param indexName Name of the index on which to perform the operation. (required)
* @param model [Recommend
* model](https://www.algolia.com/doc/guides/algolia-recommend/overview/#recommend-models).
* (required)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public CompletableFuture batchRecommendRulesAsync(@Nonnull String indexName, @Nonnull RecommendModels model)
throws AlgoliaRuntimeException {
return this.batchRecommendRulesAsync(indexName, model, null, null);
}
/**
* This method allow you to send requests to the Algolia REST API.
*
* @param path Path of the endpoint, anything after \"/1\" must be specified. (required)
* @param parameters Query parameters to apply to the current query. (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public Object customDelete(@Nonnull String path, Map parameters, RequestOptions requestOptions)
throws AlgoliaRuntimeException {
return LaunderThrowable.await(customDeleteAsync(path, parameters, requestOptions));
}
/**
* This method allow you to send requests to the Algolia REST API.
*
* @param path Path of the endpoint, anything after \"/1\" must be specified. (required)
* @param parameters Query parameters to apply to the current query. (optional)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public Object customDelete(@Nonnull String path, Map parameters) throws AlgoliaRuntimeException {
return this.customDelete(path, parameters, null);
}
/**
* This method allow you to send requests to the Algolia REST API.
*
* @param path Path of the endpoint, anything after \"/1\" must be specified. (required)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public Object customDelete(@Nonnull String path, RequestOptions requestOptions) throws AlgoliaRuntimeException {
return this.customDelete(path, null, requestOptions);
}
/**
* This method allow you to send requests to the Algolia REST API.
*
* @param path Path of the endpoint, anything after \"/1\" must be specified. (required)
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public Object customDelete(@Nonnull String path) throws AlgoliaRuntimeException {
return this.customDelete(path, null, null);
}
/**
* (asynchronously) This method allow you to send requests to the Algolia REST API.
*
* @param path Path of the endpoint, anything after \"/1\" must be specified. (required)
* @param parameters Query parameters to apply to the current query. (optional)
* @param requestOptions The requestOptions to send along with the query, they will be merged with
* the transporter requestOptions.
* @throws AlgoliaRuntimeException If it fails to process the API call
*/
public CompletableFuture