Skip to content

Commit 429fa99

Browse files
algolia-botmillotp
andcommitted
feat(specs): add runSource endpoint (generated)
algolia/api-clients-automation#3453 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 34d73c4 commit 429fa99

File tree

4 files changed

+192
-0
lines changed

4 files changed

+192
-0
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,6 +2446,73 @@ open class IngestionClient {
24462446
)
24472447
}
24482448

2449+
/// - parameter sourceID: (path) Unique identifier of a source.
2450+
/// - parameter runSourcePayload: (body) (optional)
2451+
/// - returns: RunSourceResponse
2452+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
2453+
open func runSource(
2454+
sourceID: String,
2455+
runSourcePayload: RunSourcePayload? = nil,
2456+
requestOptions: RequestOptions? = nil
2457+
) async throws -> RunSourceResponse {
2458+
let response: Response<RunSourceResponse> = try await runSourceWithHTTPInfo(
2459+
sourceID: sourceID,
2460+
runSourcePayload: runSourcePayload,
2461+
requestOptions: requestOptions
2462+
)
2463+
2464+
guard let body = response.body else {
2465+
throw AlgoliaError.missingData
2466+
}
2467+
2468+
return body
2469+
}
2470+
2471+
// Runs all tasks linked to a source, only available for Shopify sources. It will create 1 run per task.
2472+
// Required API Key ACLs:
2473+
// - addObject
2474+
// - deleteIndex
2475+
// - editSettings
2476+
//
2477+
// - parameter sourceID: (path) Unique identifier of a source.
2478+
//
2479+
// - parameter runSourcePayload: (body) (optional)
2480+
// - returns: RequestBuilder<RunSourceResponse>
2481+
2482+
open func runSourceWithHTTPInfo(
2483+
sourceID: String,
2484+
runSourcePayload: RunSourcePayload? = nil,
2485+
requestOptions userRequestOptions: RequestOptions? = nil
2486+
) async throws -> Response<RunSourceResponse> {
2487+
guard !sourceID.isEmpty else {
2488+
throw AlgoliaError.invalidArgument("sourceID", "runSource")
2489+
}
2490+
2491+
var resourcePath = "/1/sources/{sourceID}/run"
2492+
let sourceIDPreEscape = "\(APIHelper.mapValueToPathItem(sourceID))"
2493+
let sourceIDPostEscape = sourceIDPreEscape
2494+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
2495+
resourcePath = resourcePath.replacingOccurrences(
2496+
of: "{sourceID}",
2497+
with: sourceIDPostEscape,
2498+
options: .literal,
2499+
range: nil
2500+
)
2501+
let body = runSourcePayload
2502+
let queryParameters: [String: Any?]? = nil
2503+
2504+
let nillableHeaders: [String: Any?]? = nil
2505+
2506+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
2507+
2508+
return try await self.transporter.send(
2509+
method: "POST",
2510+
path: resourcePath,
2511+
data: body ?? AnyCodable(),
2512+
requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions
2513+
)
2514+
}
2515+
24492516
/// - parameter taskID: (path) Unique identifier of a task.
24502517
/// - returns: RunResponse
24512518
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
/// Type of entity to update.
10+
public enum EntityType: String, Codable, CaseIterable {
11+
case product
12+
case collection
13+
}
14+
15+
extension EntityType: Hashable {}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
public struct RunSourcePayload: Codable, JSONEncodable {
10+
/// List of index names to include in reidexing/update.
11+
public var indexToInclude: [String]?
12+
/// List of index names to exclude in reidexing/update.
13+
public var indexToExclude: [String]?
14+
/// List of entityID to update.
15+
public var entityIDs: [String]?
16+
public var entityType: EntityType?
17+
18+
public init(
19+
indexToInclude: [String]? = nil,
20+
indexToExclude: [String]? = nil,
21+
entityIDs: [String]? = nil,
22+
entityType: EntityType? = nil
23+
) {
24+
self.indexToInclude = indexToInclude
25+
self.indexToExclude = indexToExclude
26+
self.entityIDs = entityIDs
27+
self.entityType = entityType
28+
}
29+
30+
public enum CodingKeys: String, CodingKey, CaseIterable {
31+
case indexToInclude
32+
case indexToExclude
33+
case entityIDs
34+
case entityType
35+
}
36+
37+
// Encodable protocol methods
38+
39+
public func encode(to encoder: Encoder) throws {
40+
var container = encoder.container(keyedBy: CodingKeys.self)
41+
try container.encodeIfPresent(self.indexToInclude, forKey: .indexToInclude)
42+
try container.encodeIfPresent(self.indexToExclude, forKey: .indexToExclude)
43+
try container.encodeIfPresent(self.entityIDs, forKey: .entityIDs)
44+
try container.encodeIfPresent(self.entityType, forKey: .entityType)
45+
}
46+
}
47+
48+
extension RunSourcePayload: Equatable {
49+
public static func ==(lhs: RunSourcePayload, rhs: RunSourcePayload) -> Bool {
50+
lhs.indexToInclude == rhs.indexToInclude &&
51+
lhs.indexToExclude == rhs.indexToExclude &&
52+
lhs.entityIDs == rhs.entityIDs &&
53+
lhs.entityType == rhs.entityType
54+
}
55+
}
56+
57+
extension RunSourcePayload: Hashable {
58+
public func hash(into hasher: inout Hasher) {
59+
hasher.combine(self.indexToInclude?.hashValue)
60+
hasher.combine(self.indexToExclude?.hashValue)
61+
hasher.combine(self.entityIDs?.hashValue)
62+
hasher.combine(self.entityType?.hashValue)
63+
}
64+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on
2+
// https://github.com/algolia/api-clients-automation. DO NOT EDIT.
3+
4+
import Foundation
5+
#if canImport(Core)
6+
import Core
7+
#endif
8+
9+
public struct RunSourceResponse: Codable, JSONEncodable {
10+
/// Map of taskID sent for reindex with the corresponding runID.
11+
public var taskWithRunID: [String: String]
12+
/// Date of creation in RFC 3339 format.
13+
public var createdAt: String
14+
15+
public init(taskWithRunID: [String: String], createdAt: String) {
16+
self.taskWithRunID = taskWithRunID
17+
self.createdAt = createdAt
18+
}
19+
20+
public enum CodingKeys: String, CodingKey, CaseIterable {
21+
case taskWithRunID
22+
case createdAt
23+
}
24+
25+
// Encodable protocol methods
26+
27+
public func encode(to encoder: Encoder) throws {
28+
var container = encoder.container(keyedBy: CodingKeys.self)
29+
try container.encode(self.taskWithRunID, forKey: .taskWithRunID)
30+
try container.encode(self.createdAt, forKey: .createdAt)
31+
}
32+
}
33+
34+
extension RunSourceResponse: Equatable {
35+
public static func ==(lhs: RunSourceResponse, rhs: RunSourceResponse) -> Bool {
36+
lhs.taskWithRunID == rhs.taskWithRunID &&
37+
lhs.createdAt == rhs.createdAt
38+
}
39+
}
40+
41+
extension RunSourceResponse: Hashable {
42+
public func hash(into hasher: inout Hasher) {
43+
hasher.combine(self.taskWithRunID.hashValue)
44+
hasher.combine(self.createdAt.hashValue)
45+
}
46+
}

0 commit comments

Comments
 (0)