Skip to content

Commit 11796e2

Browse files
feat(specs): add put task endpoint to ingestion api (generated)
algolia/api-clients-automation#5281 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 9fa60bb commit 11796e2

File tree

3 files changed

+177
-2
lines changed

3 files changed

+177
-2
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2724,6 +2724,72 @@ open class IngestionClient {
27242724
)
27252725
}
27262726

2727+
/// - parameter taskID: (path) Unique identifier of a task.
2728+
/// - parameter taskReplace: (body)
2729+
/// - returns: TaskUpdateResponse
2730+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
2731+
open func replaceTask(
2732+
taskID: String,
2733+
taskReplace: TaskReplace,
2734+
requestOptions: RequestOptions? = nil
2735+
) async throws -> TaskUpdateResponse {
2736+
let response: Response<TaskUpdateResponse> = try await replaceTaskWithHTTPInfo(
2737+
taskID: taskID,
2738+
taskReplace: taskReplace,
2739+
requestOptions: requestOptions
2740+
)
2741+
2742+
guard let body = response.body else {
2743+
throw AlgoliaError.missingData
2744+
}
2745+
2746+
return body
2747+
}
2748+
2749+
// Fully updates a task by its ID, use partialUpdateTask if you only want to update a subset of fields.
2750+
//
2751+
//
2752+
// - parameter taskID: (path) Unique identifier of a task.
2753+
//
2754+
// - parameter taskReplace: (body)
2755+
// - returns: RequestBuilder<TaskUpdateResponse>
2756+
2757+
open func replaceTaskWithHTTPInfo(
2758+
taskID: String,
2759+
taskReplace: TaskReplace,
2760+
requestOptions userRequestOptions: RequestOptions? = nil
2761+
) async throws -> Response<TaskUpdateResponse> {
2762+
guard !taskID.isEmpty else {
2763+
throw AlgoliaError.invalidArgument("taskID", "replaceTask")
2764+
}
2765+
2766+
var resourcePath = "/2/tasks/{taskID}"
2767+
let taskIDPreEscape = "\(APIHelper.mapValueToPathItem(taskID))"
2768+
let taskIDPostEscape = taskIDPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
2769+
resourcePath = resourcePath.replacingOccurrences(
2770+
of: "{taskID}",
2771+
with: taskIDPostEscape,
2772+
options: .literal,
2773+
range: nil
2774+
)
2775+
let body = taskReplace
2776+
let queryParameters: [String: Any?]? = nil
2777+
2778+
let nillableHeaders: [String: Any?]? = nil
2779+
2780+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
2781+
2782+
return try await self.transporter.send(
2783+
method: "PUT",
2784+
path: resourcePath,
2785+
data: body,
2786+
requestOptions: RequestOptions(
2787+
headers: headers,
2788+
queryParameters: queryParameters
2789+
) + userRequestOptions
2790+
)
2791+
}
2792+
27272793
/// - parameter sourceID: (path) Unique identifier of a source.
27282794
/// - parameter runSourcePayload: (body) (optional)
27292795
/// - returns: RunSourceResponse
@@ -3661,7 +3727,7 @@ open class IngestionClient {
36613727
return body
36623728
}
36633729

3664-
// Updates a task by its ID.
3730+
// Partially updates a task by its ID.
36653731
//
36663732
//
36673733
// - parameter taskID: (path) Unique identifier of a task.
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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+
/// API request body for updating a task.
10+
public struct TaskReplace: Codable, JSONEncodable {
11+
/// Universally unique identifier (UUID) of a destination resource.
12+
public var destinationID: String
13+
public var action: ActionType
14+
public var subscriptionAction: ActionType?
15+
/// Cron expression for the task's schedule.
16+
public var cron: String?
17+
/// Whether the task is enabled.
18+
public var enabled: Bool?
19+
/// Maximum accepted percentage of failures for a task run to finish successfully.
20+
public var failureThreshold: Int?
21+
public var input: TaskInput?
22+
/// Date of the last cursor in RFC 3339 format.
23+
public var cursor: String?
24+
public var notifications: Notifications?
25+
public var policies: Policies?
26+
27+
public init(
28+
destinationID: String,
29+
action: ActionType,
30+
subscriptionAction: ActionType? = nil,
31+
cron: String? = nil,
32+
enabled: Bool? = nil,
33+
failureThreshold: Int? = nil,
34+
input: TaskInput? = nil,
35+
cursor: String? = nil,
36+
notifications: Notifications? = nil,
37+
policies: Policies? = nil
38+
) {
39+
self.destinationID = destinationID
40+
self.action = action
41+
self.subscriptionAction = subscriptionAction
42+
self.cron = cron
43+
self.enabled = enabled
44+
self.failureThreshold = failureThreshold
45+
self.input = input
46+
self.cursor = cursor
47+
self.notifications = notifications
48+
self.policies = policies
49+
}
50+
51+
public enum CodingKeys: String, CodingKey, CaseIterable {
52+
case destinationID
53+
case action
54+
case subscriptionAction
55+
case cron
56+
case enabled
57+
case failureThreshold
58+
case input
59+
case cursor
60+
case notifications
61+
case policies
62+
}
63+
64+
// Encodable protocol methods
65+
66+
public func encode(to encoder: Encoder) throws {
67+
var container = encoder.container(keyedBy: CodingKeys.self)
68+
try container.encode(self.destinationID, forKey: .destinationID)
69+
try container.encode(self.action, forKey: .action)
70+
try container.encodeIfPresent(self.subscriptionAction, forKey: .subscriptionAction)
71+
try container.encodeIfPresent(self.cron, forKey: .cron)
72+
try container.encodeIfPresent(self.enabled, forKey: .enabled)
73+
try container.encodeIfPresent(self.failureThreshold, forKey: .failureThreshold)
74+
try container.encodeIfPresent(self.input, forKey: .input)
75+
try container.encodeIfPresent(self.cursor, forKey: .cursor)
76+
try container.encodeIfPresent(self.notifications, forKey: .notifications)
77+
try container.encodeIfPresent(self.policies, forKey: .policies)
78+
}
79+
}
80+
81+
extension TaskReplace: Equatable {
82+
public static func ==(lhs: TaskReplace, rhs: TaskReplace) -> Bool {
83+
lhs.destinationID == rhs.destinationID &&
84+
lhs.action == rhs.action &&
85+
lhs.subscriptionAction == rhs.subscriptionAction &&
86+
lhs.cron == rhs.cron &&
87+
lhs.enabled == rhs.enabled &&
88+
lhs.failureThreshold == rhs.failureThreshold &&
89+
lhs.input == rhs.input &&
90+
lhs.cursor == rhs.cursor &&
91+
lhs.notifications == rhs.notifications &&
92+
lhs.policies == rhs.policies
93+
}
94+
}
95+
96+
extension TaskReplace: Hashable {
97+
public func hash(into hasher: inout Hasher) {
98+
hasher.combine(self.destinationID.hashValue)
99+
hasher.combine(self.action.hashValue)
100+
hasher.combine(self.subscriptionAction?.hashValue)
101+
hasher.combine(self.cron?.hashValue)
102+
hasher.combine(self.enabled?.hashValue)
103+
hasher.combine(self.failureThreshold?.hashValue)
104+
hasher.combine(self.input?.hashValue)
105+
hasher.combine(self.cursor?.hashValue)
106+
hasher.combine(self.notifications?.hashValue)
107+
hasher.combine(self.policies?.hashValue)
108+
}
109+
}

Sources/Ingestion/Models/TaskUpdate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Foundation
66
import Core
77
#endif
88

9-
/// API request body for updating a task.
9+
/// API request body for partially updating a task.
1010
public struct TaskUpdate: Codable, JSONEncodable {
1111
/// Universally unique identifier (UUID) of a destination resource.
1212
public var destinationID: String?

0 commit comments

Comments
 (0)