Skip to content

Commit 8c8b1bf

Browse files
feat(specs): add global push endpoint (generated)
algolia/api-clients-automation#4855 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent eb40d6c commit 8c8b1bf

File tree

2 files changed

+93
-9
lines changed

2 files changed

+93
-9
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 93 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,9 +2546,94 @@ open class IngestionClient {
25462546
)
25472547
}
25482548

2549+
/// - parameter indexName: (path) Name of the index on which to perform the operation.
2550+
/// - parameter pushTaskPayload: (body)
2551+
/// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
2552+
/// ingestion to be finished before responding. (optional)
2553+
/// - returns: WatchResponse
2554+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
2555+
open func push(
2556+
indexName: String,
2557+
pushTaskPayload: PushTaskPayload,
2558+
watch: Bool? = nil,
2559+
requestOptions: RequestOptions? = nil
2560+
) async throws -> WatchResponse {
2561+
let response: Response<WatchResponse> = try await pushWithHTTPInfo(
2562+
indexName: indexName,
2563+
pushTaskPayload: pushTaskPayload,
2564+
watch: watch,
2565+
requestOptions: requestOptions
2566+
)
2567+
2568+
guard let body = response.body else {
2569+
throw AlgoliaError.missingData
2570+
}
2571+
2572+
return body
2573+
}
2574+
2575+
// Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the
2576+
// `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to
2577+
// see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/),
2578+
// this is the recommended way of ingesting your records. This method is similar to `pushTask`, but requires an
2579+
// `indexName` instead of a `taskID`. If zero or many tasks are found, an error will be returned.
2580+
// Required API Key ACLs:
2581+
// - addObject
2582+
// - deleteIndex
2583+
// - editSettings
2584+
//
2585+
// - parameter indexName: (path) Name of the index on which to perform the operation.
2586+
//
2587+
// - parameter pushTaskPayload: (body)
2588+
//
2589+
// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
2590+
// ingestion to be finished before responding. (optional)
2591+
// - returns: RequestBuilder<WatchResponse>
2592+
2593+
open func pushWithHTTPInfo(
2594+
indexName: String,
2595+
pushTaskPayload: PushTaskPayload,
2596+
watch: Bool? = nil,
2597+
requestOptions userRequestOptions: RequestOptions? = nil
2598+
) async throws -> Response<WatchResponse> {
2599+
guard !indexName.isEmpty else {
2600+
throw AlgoliaError.invalidArgument("indexName", "push")
2601+
}
2602+
2603+
var resourcePath = "/1/push/{indexName}"
2604+
let indexNamePreEscape = "\(APIHelper.mapValueToPathItem(indexName))"
2605+
let indexNamePostEscape = indexNamePreEscape
2606+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
2607+
resourcePath = resourcePath.replacingOccurrences(
2608+
of: "{indexName}",
2609+
with: indexNamePostEscape,
2610+
options: .literal,
2611+
range: nil
2612+
)
2613+
let body = pushTaskPayload
2614+
let queryParameters: [String: Any?] = [
2615+
"watch": watch?.encodeToJSON(),
2616+
]
2617+
2618+
let nillableHeaders: [String: Any?]? = nil
2619+
2620+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
2621+
2622+
return try await self.transporter.send(
2623+
method: "POST",
2624+
path: resourcePath,
2625+
data: body,
2626+
requestOptions: RequestOptions(
2627+
headers: headers,
2628+
queryParameters: queryParameters,
2629+
readTimeout: 180,
2630+
writeTimeout: 180
2631+
) + userRequestOptions
2632+
)
2633+
}
2634+
25492635
/// - parameter taskID: (path) Unique identifier of a task.
2550-
/// - parameter pushTaskPayload: (body) Request body of a Search API `batch` request that will be pushed in the
2551-
/// Connectors pipeline.
2636+
/// - parameter pushTaskPayload: (body)
25522637
/// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
25532638
/// ingestion to be finished before responding. (optional)
25542639
/// - returns: WatchResponse
@@ -2573,17 +2658,19 @@ open class IngestionClient {
25732658
return body
25742659
}
25752660

2576-
// Push a `batch` request payload through the Pipeline. You can check the status of task pushes with the
2577-
// observability endpoints.
2661+
// Pushes records through the Pipeline, directly to an index. You can make the call synchronous by providing the
2662+
// `watch` parameter, for asynchronous calls, you can use the observability endpoints and/or debugger dashboard to
2663+
// see the status of your task. If you want to leverage the [pre-indexing data transformation](https://www.algolia.com/doc/guides/sending-and-managing-data/send-and-update-your-data/how-to/transform-your-data/),
2664+
// this is the recommended way of ingesting your records. This method is similar to `push`, but requires a `taskID`
2665+
// instead of a `indexName`, which is useful when many `destinations` target the same `indexName`.
25782666
// Required API Key ACLs:
25792667
// - addObject
25802668
// - deleteIndex
25812669
// - editSettings
25822670
//
25832671
// - parameter taskID: (path) Unique identifier of a task.
25842672
//
2585-
// - parameter pushTaskPayload: (body) Request body of a Search API `batch` request that will be pushed in the
2586-
// Connectors pipeline.
2673+
// - parameter pushTaskPayload: (body)
25872674
//
25882675
// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
25892676
// ingestion to be finished before responding. (optional)

Sources/Ingestion/Models/IngestionAction.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ public enum IngestionAction: String, Codable, CaseIterable {
1212
case updateObject
1313
case partialUpdateObject
1414
case partialUpdateObjectNoCreate
15-
case deleteObject
16-
case delete
17-
case clear
1815
}
1916

2017
extension IngestionAction: Hashable {}

0 commit comments

Comments
 (0)