Skip to content

Commit 329e8f8

Browse files
feat(specs): add with transformation helpers (generated)
algolia/api-clients-automation#4931 Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com> Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
1 parent 03dbc71 commit 329e8f8

9 files changed

+259
-51
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,10 +1347,14 @@ open class IngestionClient {
13471347

13481348
/// - parameter runID: (path) Unique identifier of a task run.
13491349
/// - parameter eventID: (path) Unique identifier of an event.
1350-
/// - returns: Event
1350+
/// - returns: IngestionEvent
13511351
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
1352-
open func getEvent(runID: String, eventID: String, requestOptions: RequestOptions? = nil) async throws -> Event {
1353-
let response: Response<Event> = try await getEventWithHTTPInfo(
1352+
open func getEvent(
1353+
runID: String,
1354+
eventID: String,
1355+
requestOptions: RequestOptions? = nil
1356+
) async throws -> IngestionEvent {
1357+
let response: Response<IngestionEvent> = try await getEventWithHTTPInfo(
13541358
runID: runID,
13551359
eventID: eventID,
13561360
requestOptions: requestOptions
@@ -1372,13 +1376,13 @@ open class IngestionClient {
13721376
// - parameter runID: (path) Unique identifier of a task run.
13731377
//
13741378
// - parameter eventID: (path) Unique identifier of an event.
1375-
// - returns: RequestBuilder<Event>
1379+
// - returns: RequestBuilder<IngestionEvent>
13761380

13771381
open func getEventWithHTTPInfo(
13781382
runID: String,
13791383
eventID: String,
13801384
requestOptions userRequestOptions: RequestOptions? = nil
1381-
) async throws -> Response<Event> {
1385+
) async throws -> Response<IngestionEvent> {
13821386
guard !runID.isEmpty else {
13831387
throw AlgoliaError.invalidArgument("runID", "getEvent")
13841388
}
@@ -1926,7 +1930,7 @@ open class IngestionClient {
19261930
runID: String,
19271931
itemsPerPage: Int? = nil,
19281932
page: Int? = nil,
1929-
status: [EventStatus]? = nil,
1933+
status: [IngestionEventStatus]? = nil,
19301934
type: [IngestionEventType]? = nil,
19311935
sort: EventSortKeys? = nil,
19321936
order: OrderKeys? = nil,
@@ -1985,7 +1989,7 @@ open class IngestionClient {
19851989
runID: String,
19861990
itemsPerPage: Int? = nil,
19871991
page: Int? = nil,
1988-
status: [EventStatus]? = nil,
1992+
status: [IngestionEventStatus]? = nil,
19891993
type: [IngestionEventType]? = nil,
19901994
sort: EventSortKeys? = nil,
19911995
order: OrderKeys? = nil,
@@ -2550,15 +2554,15 @@ open class IngestionClient {
25502554
/// - parameter pushTaskPayload: (body)
25512555
/// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
25522556
/// ingestion to be finished before responding. (optional)
2553-
/// - returns: WatchResponse
2557+
/// - returns: IngestionWatchResponse
25542558
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
25552559
open func push(
25562560
indexName: String,
25572561
pushTaskPayload: PushTaskPayload,
25582562
watch: Bool? = nil,
25592563
requestOptions: RequestOptions? = nil
2560-
) async throws -> WatchResponse {
2561-
let response: Response<WatchResponse> = try await pushWithHTTPInfo(
2564+
) async throws -> IngestionWatchResponse {
2565+
let response: Response<IngestionWatchResponse> = try await pushWithHTTPInfo(
25622566
indexName: indexName,
25632567
pushTaskPayload: pushTaskPayload,
25642568
watch: watch,
@@ -2588,14 +2592,14 @@ open class IngestionClient {
25882592
//
25892593
// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
25902594
// ingestion to be finished before responding. (optional)
2591-
// - returns: RequestBuilder<WatchResponse>
2595+
// - returns: RequestBuilder<IngestionWatchResponse>
25922596

25932597
open func pushWithHTTPInfo(
25942598
indexName: String,
25952599
pushTaskPayload: PushTaskPayload,
25962600
watch: Bool? = nil,
25972601
requestOptions userRequestOptions: RequestOptions? = nil
2598-
) async throws -> Response<WatchResponse> {
2602+
) async throws -> Response<IngestionWatchResponse> {
25992603
guard !indexName.isEmpty else {
26002604
throw AlgoliaError.invalidArgument("indexName", "push")
26012605
}
@@ -2636,15 +2640,15 @@ open class IngestionClient {
26362640
/// - parameter pushTaskPayload: (body)
26372641
/// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
26382642
/// ingestion to be finished before responding. (optional)
2639-
/// - returns: WatchResponse
2643+
/// - returns: IngestionWatchResponse
26402644
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
26412645
open func pushTask(
26422646
taskID: String,
26432647
pushTaskPayload: PushTaskPayload,
26442648
watch: Bool? = nil,
26452649
requestOptions: RequestOptions? = nil
2646-
) async throws -> WatchResponse {
2647-
let response: Response<WatchResponse> = try await pushTaskWithHTTPInfo(
2650+
) async throws -> IngestionWatchResponse {
2651+
let response: Response<IngestionWatchResponse> = try await pushTaskWithHTTPInfo(
26482652
taskID: taskID,
26492653
pushTaskPayload: pushTaskPayload,
26502654
watch: watch,
@@ -2674,14 +2678,14 @@ open class IngestionClient {
26742678
//
26752679
// - parameter watch: (query) When provided, the push operation will be synchronous and the API will wait for the
26762680
// ingestion to be finished before responding. (optional)
2677-
// - returns: RequestBuilder<WatchResponse>
2681+
// - returns: RequestBuilder<IngestionWatchResponse>
26782682

26792683
open func pushTaskWithHTTPInfo(
26802684
taskID: String,
26812685
pushTaskPayload: PushTaskPayload,
26822686
watch: Bool? = nil,
26832687
requestOptions userRequestOptions: RequestOptions? = nil
2684-
) async throws -> Response<WatchResponse> {
2688+
) async throws -> Response<IngestionWatchResponse> {
26852689
guard !taskID.isEmpty else {
26862690
throw AlgoliaError.invalidArgument("taskID", "pushTask")
26872691
}
@@ -3219,13 +3223,13 @@ open class IngestionClient {
32193223
}
32203224

32213225
/// - parameter sourceID: (path) Unique identifier of a source.
3222-
/// - returns: WatchResponse
3226+
/// - returns: IngestionWatchResponse
32233227
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
32243228
open func triggerDockerSourceDiscover(
32253229
sourceID: String,
32263230
requestOptions: RequestOptions? = nil
3227-
) async throws -> WatchResponse {
3228-
let response: Response<WatchResponse> = try await triggerDockerSourceDiscoverWithHTTPInfo(
3231+
) async throws -> IngestionWatchResponse {
3232+
let response: Response<IngestionWatchResponse> = try await triggerDockerSourceDiscoverWithHTTPInfo(
32293233
sourceID: sourceID,
32303234
requestOptions: requestOptions
32313235
)
@@ -3245,12 +3249,12 @@ open class IngestionClient {
32453249
// - editSettings
32463250
//
32473251
// - parameter sourceID: (path) Unique identifier of a source.
3248-
// - returns: RequestBuilder<WatchResponse>
3252+
// - returns: RequestBuilder<IngestionWatchResponse>
32493253

32503254
open func triggerDockerSourceDiscoverWithHTTPInfo(
32513255
sourceID: String,
32523256
requestOptions userRequestOptions: RequestOptions? = nil
3253-
) async throws -> Response<WatchResponse> {
3257+
) async throws -> Response<IngestionWatchResponse> {
32543258
guard !sourceID.isEmpty else {
32553259
throw AlgoliaError.invalidArgument("sourceID", "triggerDockerSourceDiscover")
32563260
}
@@ -3820,13 +3824,13 @@ open class IngestionClient {
38203824
}
38213825

38223826
/// - parameter sourceCreate: (body) (optional)
3823-
/// - returns: WatchResponse
3827+
/// - returns: IngestionWatchResponse
38243828
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
38253829
open func validateSource(
38263830
sourceCreate: SourceCreate? = nil,
38273831
requestOptions: RequestOptions? = nil
3828-
) async throws -> WatchResponse {
3829-
let response: Response<WatchResponse> = try await validateSourceWithHTTPInfo(
3832+
) async throws -> IngestionWatchResponse {
3833+
let response: Response<IngestionWatchResponse> = try await validateSourceWithHTTPInfo(
38303834
sourceCreate: sourceCreate,
38313835
requestOptions: requestOptions
38323836
)
@@ -3845,12 +3849,12 @@ open class IngestionClient {
38453849
// - editSettings
38463850
//
38473851
// - parameter sourceCreate: (body) (optional)
3848-
// - returns: RequestBuilder<WatchResponse>
3852+
// - returns: RequestBuilder<IngestionWatchResponse>
38493853

38503854
open func validateSourceWithHTTPInfo(
38513855
sourceCreate: SourceCreate? = nil,
38523856
requestOptions userRequestOptions: RequestOptions? = nil
3853-
) async throws -> Response<WatchResponse> {
3857+
) async throws -> Response<IngestionWatchResponse> {
38543858
let resourcePath = "/1/sources/validate"
38553859
let body = sourceCreate
38563860
let queryParameters: [String: Any?]? = nil
@@ -3874,14 +3878,14 @@ open class IngestionClient {
38743878

38753879
/// - parameter sourceID: (path) Unique identifier of a source.
38763880
/// - parameter sourceUpdate: (body)
3877-
/// - returns: WatchResponse
3881+
/// - returns: IngestionWatchResponse
38783882
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
38793883
open func validateSourceBeforeUpdate(
38803884
sourceID: String,
38813885
sourceUpdate: SourceUpdate,
38823886
requestOptions: RequestOptions? = nil
3883-
) async throws -> WatchResponse {
3884-
let response: Response<WatchResponse> = try await validateSourceBeforeUpdateWithHTTPInfo(
3887+
) async throws -> IngestionWatchResponse {
3888+
let response: Response<IngestionWatchResponse> = try await validateSourceBeforeUpdateWithHTTPInfo(
38853889
sourceID: sourceID,
38863890
sourceUpdate: sourceUpdate,
38873891
requestOptions: requestOptions
@@ -3904,13 +3908,13 @@ open class IngestionClient {
39043908
// - parameter sourceID: (path) Unique identifier of a source.
39053909
//
39063910
// - parameter sourceUpdate: (body)
3907-
// - returns: RequestBuilder<WatchResponse>
3911+
// - returns: RequestBuilder<IngestionWatchResponse>
39083912

39093913
open func validateSourceBeforeUpdateWithHTTPInfo(
39103914
sourceID: String,
39113915
sourceUpdate: SourceUpdate,
39123916
requestOptions userRequestOptions: RequestOptions? = nil
3913-
) async throws -> Response<WatchResponse> {
3917+
) async throws -> Response<IngestionWatchResponse> {
39143918
guard !sourceID.isEmpty else {
39153919
throw AlgoliaError.invalidArgument("sourceID", "validateSourceBeforeUpdate")
39163920
}

Sources/Ingestion/Models/Event.swift renamed to Sources/Ingestion/Models/IngestionEvent.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import Foundation
77
#endif
88

99
/// An event describe a step of the task execution flow..
10-
public struct Event: Codable, JSONEncodable {
10+
public struct IngestionEvent: Codable, JSONEncodable {
1111
/// Universally unique identifier (UUID) of an event.
1212
public var eventID: String
1313
/// Universally unique identifier (UUID) of a task run.
1414
public var runID: String
15-
public var status: EventStatus?
15+
public var status: IngestionEventStatus?
1616
public var type: IngestionEventType
1717
/// The extracted record batch size.
1818
public var batchSize: Int
@@ -23,7 +23,7 @@ public struct Event: Codable, JSONEncodable {
2323
public init(
2424
eventID: String,
2525
runID: String,
26-
status: EventStatus?,
26+
status: IngestionEventStatus?,
2727
type: IngestionEventType,
2828
batchSize: Int,
2929
data: [String: AnyCodable]? = nil,
@@ -62,8 +62,8 @@ public struct Event: Codable, JSONEncodable {
6262
}
6363
}
6464

65-
extension Event: Equatable {
66-
public static func ==(lhs: Event, rhs: Event) -> Bool {
65+
extension IngestionEvent: Equatable {
66+
public static func ==(lhs: IngestionEvent, rhs: IngestionEvent) -> Bool {
6767
lhs.eventID == rhs.eventID &&
6868
lhs.runID == rhs.runID &&
6969
lhs.status == rhs.status &&
@@ -74,7 +74,7 @@ extension Event: Equatable {
7474
}
7575
}
7676

77-
extension Event: Hashable {
77+
extension IngestionEvent: Hashable {
7878
public func hash(into hasher: inout Hasher) {
7979
hasher.combine(self.eventID.hashValue)
8080
hasher.combine(self.runID.hashValue)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
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 enum IngestionEventStatus: String, Codable, CaseIterable {
10+
case created
11+
case started
12+
case retried
13+
case failed
14+
case succeeded
15+
case critical
16+
}
17+
18+
extension IngestionEventStatus: Hashable {}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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 IngestionWatchResponse: Codable, JSONEncodable {
10+
/// Universally unique identifier (UUID) of a task run.
11+
public var runID: String
12+
/// Universally unique identifier (UUID) of an event.
13+
public var eventID: String?
14+
/// This field is always null when used with the Push endpoint. When used for a source discover or source validate
15+
/// run, it will include the sampled data of the source.
16+
public var data: [AnyCodable]?
17+
/// in case of error, observability events will be added to the response.
18+
public var events: [IngestionEvent]?
19+
/// a message describing the outcome of the operation that has been ran (push, discover or validate) run.
20+
public var message: String?
21+
/// Date of creation in RFC 3339 format.
22+
public var createdAt: String?
23+
24+
public init(
25+
runID: String,
26+
eventID: String? = nil,
27+
data: [AnyCodable]? = nil,
28+
events: [IngestionEvent]? = nil,
29+
message: String? = nil,
30+
createdAt: String? = nil
31+
) {
32+
self.runID = runID
33+
self.eventID = eventID
34+
self.data = data
35+
self.events = events
36+
self.message = message
37+
self.createdAt = createdAt
38+
}
39+
40+
public enum CodingKeys: String, CodingKey, CaseIterable {
41+
case runID
42+
case eventID
43+
case data
44+
case events
45+
case message
46+
case createdAt
47+
}
48+
49+
// Encodable protocol methods
50+
51+
public func encode(to encoder: Encoder) throws {
52+
var container = encoder.container(keyedBy: CodingKeys.self)
53+
try container.encode(self.runID, forKey: .runID)
54+
try container.encodeIfPresent(self.eventID, forKey: .eventID)
55+
try container.encodeIfPresent(self.data, forKey: .data)
56+
try container.encodeIfPresent(self.events, forKey: .events)
57+
try container.encodeIfPresent(self.message, forKey: .message)
58+
try container.encodeIfPresent(self.createdAt, forKey: .createdAt)
59+
}
60+
}
61+
62+
extension IngestionWatchResponse: Equatable {
63+
public static func ==(lhs: IngestionWatchResponse, rhs: IngestionWatchResponse) -> Bool {
64+
lhs.runID == rhs.runID &&
65+
lhs.eventID == rhs.eventID &&
66+
lhs.data == rhs.data &&
67+
lhs.events == rhs.events &&
68+
lhs.message == rhs.message &&
69+
lhs.createdAt == rhs.createdAt
70+
}
71+
}
72+
73+
extension IngestionWatchResponse: Hashable {
74+
public func hash(into hasher: inout Hasher) {
75+
hasher.combine(self.runID.hashValue)
76+
hasher.combine(self.eventID?.hashValue)
77+
hasher.combine(self.data?.hashValue)
78+
hasher.combine(self.events?.hashValue)
79+
hasher.combine(self.message?.hashValue)
80+
hasher.combine(self.createdAt?.hashValue)
81+
}
82+
}

Sources/Ingestion/Models/ListEventsResponse.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ import Foundation
77
#endif
88

99
public struct ListEventsResponse: Codable, JSONEncodable {
10-
public var events: [Event]
10+
public var events: [IngestionEvent]
1111
public var pagination: Pagination
1212
public var window: Window
1313

14-
public init(events: [Event], pagination: Pagination, window: Window) {
14+
public init(events: [IngestionEvent], pagination: Pagination, window: Window) {
1515
self.events = events
1616
self.pagination = pagination
1717
self.window = window

0 commit comments

Comments
 (0)