From 16caef3de6f0851f0efdfebb90596cd5c4116991 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Mon, 28 Oct 2024 16:19:18 +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 --- Sources/Search/Extra/SearchClientExtension.swift | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Sources/Search/Extra/SearchClientExtension.swift b/Sources/Search/Extra/SearchClientExtension.swift index e52ad5bd..fefa966a 100644 --- a/Sources/Search/Extra/SearchClientExtension.swift +++ b/Sources/Search/Extra/SearchClientExtension.swift @@ -463,18 +463,20 @@ public extension SearchClient { /// which creates a `batch` requests with at most 1000 objects in it. /// - parameter indexName: The name of the index where to save the objects /// - parameter objects: The new objects + /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one /// - parameter requestOptions: The request options /// - returns: [BatchResponse] func saveObjects( indexName: String, objects: [some Encodable], + waitForTasks: Bool = false, requestOptions: RequestOptions? = nil ) async throws -> [BatchResponse] { try await self.chunkedBatch( indexName: indexName, objects: objects, action: .addObject, - waitForTasks: false, + waitForTasks: waitForTasks, batchSize: 1000, requestOptions: requestOptions ) @@ -484,18 +486,20 @@ public extension SearchClient { /// creates a `batch` requests with at most 1000 objectIDs in it. /// - parameter indexName: The name of the index to delete objectIDs from /// - parameter objectIDs: The objectIDs to delete + /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one /// - parameter requestOptions: The request options /// - returns: [BatchResponse] func deleteObjects( indexName: String, objectIDs: [String], + waitForTasks: Bool = false, requestOptions: RequestOptions? = nil ) async throws -> [BatchResponse] { try await self.chunkedBatch( indexName: indexName, objects: objectIDs.map { AnyCodable(["objectID": $0]) }, action: .deleteObject, - waitForTasks: false, + waitForTasks: waitForTasks, batchSize: 1000, requestOptions: requestOptions ) @@ -507,19 +511,21 @@ public extension SearchClient { /// - parameter objects: The objects to update /// - parameter createIfNotExists: To be provided if non-existing objects are passed, otherwise, the call will /// fail.. + /// - parameter waitForTasks: If we should wait for the batch task to be finished before processing the next one /// - parameter requestOptions: The request options /// - returns: [BatchResponse] func partialUpdateObjects( indexName: String, objects: [some Encodable], createIfNotExists: Bool = false, + waitForTasks: Bool = false, requestOptions: RequestOptions? = nil ) async throws -> [BatchResponse] { try await self.chunkedBatch( indexName: indexName, objects: objects, action: createIfNotExists ? .partialUpdateObject : .partialUpdateObjectNoCreate, - waitForTasks: false, + waitForTasks: waitForTasks, batchSize: 1000, requestOptions: requestOptions )