From f6c04448a4a54bcf14b3afc35d018c9b94f4ceba Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Mon, 28 Oct 2024 16:19:09 +0000 Subject: [PATCH] feat(clients): expose waitForTasks to batch helpers [skip-bc] (generated) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/algolia/api-clients-automation/pull/4030 Co-authored-by: algolia-bot Co-authored-by: Clément Vannicatte --- .../java/com/algolia/api/SearchClient.java | 68 +++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/algoliasearch/src/main/java/com/algolia/api/SearchClient.java b/algoliasearch/src/main/java/com/algolia/api/SearchClient.java index f4267198..9f2844d5 100644 --- a/algoliasearch/src/main/java/com/algolia/api/SearchClient.java +++ b/algoliasearch/src/main/java/com/algolia/api/SearchClient.java @@ -6516,7 +6516,23 @@ public List saveObjects(String indexName, Iterable objects * the transporter requestOptions. (optional) */ public List saveObjects(String indexName, Iterable objects, RequestOptions requestOptions) { - return chunkedBatch(indexName, objects, Action.ADD_OBJECT, false, 1000, requestOptions); + return saveObjects(indexName, objects, false, requestOptions); + } + + /** + * Helper: Saves the given array of objects in the given index. The `chunkedBatch` helper is used + * under the hood, which creates a `batch` requests with at most 1000 objects in it. + * + * @param indexName The `indexName` to replace `objects` in. + * @param objects The array of `objects` to store in the given Algolia `indexName`. + * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been + * processed, this operation may slow the total execution time of this method but is more + * reliable. + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. (optional) + */ + public List saveObjects(String indexName, Iterable objects, boolean waitForTasks, RequestOptions requestOptions) { + return chunkedBatch(indexName, objects, Action.ADD_OBJECT, waitForTasks, 1000, requestOptions); } /** @@ -6527,7 +6543,7 @@ public List saveObjects(String indexName, Iterable objects * @param objectIDs The array of `objectIDs` to delete from the `indexName`. */ public List deleteObjects(String indexName, List objectIDs) { - return deleteObjects(indexName, objectIDs, null); + return deleteObjects(indexName, objectIDs, false, null); } /** @@ -6540,6 +6556,22 @@ public List deleteObjects(String indexName, List objectID * the transporter requestOptions. (optional) */ public List deleteObjects(String indexName, List objectIDs, RequestOptions requestOptions) { + return deleteObjects(indexName, objectIDs, false, null); + } + + /** + * Helper: Deletes every records for the given objectIDs. The `chunkedBatch` helper is used under + * the hood, which creates a `batch` requests with at most 1000 objectIDs in it. + * + * @param indexName The `indexName` to delete `objectIDs` from. + * @param objectIDs The array of `objectIDs` to delete from the `indexName`. + * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been + * processed, this operation may slow the total execution time of this method but is more + * reliable. + * @param requestOptions The requestOptions to send along with the query, they will be merged with + * the transporter requestOptions. (optional) + */ + public List deleteObjects(String indexName, List objectIDs, boolean waitForTasks, RequestOptions requestOptions) { List> objects = new ArrayList<>(); for (String id : objectIDs) { @@ -6548,7 +6580,7 @@ public List deleteObjects(String indexName, List objectID objects.add(obj); } - return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, false, 1000, requestOptions); + return chunkedBatch(indexName, objects, Action.DELETE_OBJECT, waitForTasks, 1000, requestOptions); } /** @@ -6562,7 +6594,29 @@ public List deleteObjects(String indexName, List objectID * will fail. */ public List partialUpdateObjects(String indexName, Iterable objects, boolean createIfNotExists) { - return partialUpdateObjects(indexName, objects, createIfNotExists, null); + return partialUpdateObjects(indexName, objects, createIfNotExists, false, null); + } + + /** + * Helper: Replaces object content of all the given objects according to their respective + * `objectID` field. The `chunkedBatch` helper is used under the hood, which creates a `batch` + * requests with at most 1000 objects in it. + * + * @param indexName The `indexName` to update `objects` in. + * @param objects The array of `objects` to update in the given Algolia `indexName`. + * @param createIfNotExists To be provided if non-existing objects are passed, otherwise, the call + * will fail. + * @param waitForTasks - Whether or not we should wait until every `batch` tasks has been + * processed, this operation may slow the total execution time of this method but is more + * reliable. + */ + public List partialUpdateObjects( + String indexName, + Iterable objects, + boolean createIfNotExists, + boolean waitForTasks + ) { + return partialUpdateObjects(indexName, objects, createIfNotExists, waitForTasks, null); } /** @@ -6574,6 +6628,9 @@ public List partialUpdateObjects(String indexName, Iterable List partialUpdateObjects( String indexName, Iterable objects, boolean createIfNotExists, + boolean waitForTasks, RequestOptions requestOptions ) { return chunkedBatch( indexName, objects, createIfNotExists ? Action.PARTIAL_UPDATE_OBJECT : Action.PARTIAL_UPDATE_OBJECT_NO_CREATE, - false, + waitForTasks, 1000, requestOptions );