diff --git a/Sources/Ingestion/IngestionClient.swift b/Sources/Ingestion/IngestionClient.swift index 1066fbc4..5ced3ee3 100644 --- a/Sources/Ingestion/IngestionClient.swift +++ b/Sources/Ingestion/IngestionClient.swift @@ -2486,18 +2486,18 @@ open class IngestionClient { } /// - parameter taskID: (path) Unique identifier of a task. - /// - parameter batchWriteParams: (body) Request body of a Search API `batch` request that will be pushed in the + /// - parameter pushTaskPayload: (body) Request body of a Search API `batch` request that will be pushed in the /// Connectors pipeline. /// - returns: RunResponse @available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) open func pushTask( taskID: String, - batchWriteParams: IngestionBatchWriteParams, + pushTaskPayload: PushTaskPayload, requestOptions: RequestOptions? = nil ) async throws -> RunResponse { let response: Response = try await pushTaskWithHTTPInfo( taskID: taskID, - batchWriteParams: batchWriteParams, + pushTaskPayload: pushTaskPayload, requestOptions: requestOptions ) @@ -2517,13 +2517,13 @@ open class IngestionClient { // // - parameter taskID: (path) Unique identifier of a task. // - // - parameter batchWriteParams: (body) Request body of a Search API `batch` request that will be pushed in the + // - parameter pushTaskPayload: (body) Request body of a Search API `batch` request that will be pushed in the // Connectors pipeline. // - returns: RequestBuilder open func pushTaskWithHTTPInfo( taskID: String, - batchWriteParams: IngestionBatchWriteParams, + pushTaskPayload: PushTaskPayload, requestOptions userRequestOptions: RequestOptions? = nil ) async throws -> Response { guard !taskID.isEmpty else { @@ -2540,7 +2540,7 @@ open class IngestionClient { options: .literal, range: nil ) - let body = batchWriteParams + let body = pushTaskPayload let queryParameters: [String: Any?]? = nil let nillableHeaders: [String: Any?]? = nil diff --git a/Sources/Ingestion/Models/IngestionBatchWriteParams.swift b/Sources/Ingestion/Models/IngestionBatchWriteParams.swift deleted file mode 100644 index b0c3cb68..00000000 --- a/Sources/Ingestion/Models/IngestionBatchWriteParams.swift +++ /dev/null @@ -1,39 +0,0 @@ -// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on -// https://github.com/algolia/api-clients-automation. DO NOT EDIT. - -import Foundation -#if canImport(Core) - import Core -#endif - -/// Batch parameters. -public struct IngestionBatchWriteParams: Codable, JSONEncodable { - public var requests: [IngestionBatchRequest] - - public init(requests: [IngestionBatchRequest]) { - self.requests = requests - } - - public enum CodingKeys: String, CodingKey, CaseIterable { - case requests - } - - // Encodable protocol methods - - public func encode(to encoder: Encoder) throws { - var container = encoder.container(keyedBy: CodingKeys.self) - try container.encode(self.requests, forKey: .requests) - } -} - -extension IngestionBatchWriteParams: Equatable { - public static func ==(lhs: IngestionBatchWriteParams, rhs: IngestionBatchWriteParams) -> Bool { - lhs.requests == rhs.requests - } -} - -extension IngestionBatchWriteParams: Hashable { - public func hash(into hasher: inout Hasher) { - hasher.combine(self.requests.hashValue) - } -} diff --git a/Sources/Ingestion/Models/IngestionBatchRequest.swift b/Sources/Ingestion/Models/PushTaskPayload.swift similarity index 57% rename from Sources/Ingestion/Models/IngestionBatchRequest.swift rename to Sources/Ingestion/Models/PushTaskPayload.swift index bc795c60..278ede61 100644 --- a/Sources/Ingestion/Models/IngestionBatchRequest.swift +++ b/Sources/Ingestion/Models/PushTaskPayload.swift @@ -6,19 +6,18 @@ import Foundation import Core #endif -public struct IngestionBatchRequest: Codable, JSONEncodable { +public struct PushTaskPayload: Codable, JSONEncodable { public var action: IngestionAction - /// Operation arguments (varies with specified `action`). - public var body: AnyCodable + public var records: [PushTaskRecords] - public init(action: IngestionAction, body: AnyCodable) { + public init(action: IngestionAction, records: [PushTaskRecords]) { self.action = action - self.body = body + self.records = records } public enum CodingKeys: String, CodingKey, CaseIterable { case action - case body + case records } // Encodable protocol methods @@ -26,20 +25,20 @@ public struct IngestionBatchRequest: Codable, JSONEncodable { public func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(self.action, forKey: .action) - try container.encode(self.body, forKey: .body) + try container.encode(self.records, forKey: .records) } } -extension IngestionBatchRequest: Equatable { - public static func ==(lhs: IngestionBatchRequest, rhs: IngestionBatchRequest) -> Bool { +extension PushTaskPayload: Equatable { + public static func ==(lhs: PushTaskPayload, rhs: PushTaskPayload) -> Bool { lhs.action == rhs.action && - lhs.body == rhs.body + lhs.records == rhs.records } } -extension IngestionBatchRequest: Hashable { +extension PushTaskPayload: Hashable { public func hash(into hasher: inout Hasher) { hasher.combine(self.action.hashValue) - hasher.combine(self.body.hashValue) + hasher.combine(self.records.hashValue) } } diff --git a/Sources/Ingestion/Models/PushTaskRecords.swift b/Sources/Ingestion/Models/PushTaskRecords.swift new file mode 100644 index 00000000..5117cdcf --- /dev/null +++ b/Sources/Ingestion/Models/PushTaskRecords.swift @@ -0,0 +1,88 @@ +// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on +// https://github.com/algolia/api-clients-automation. DO NOT EDIT. + +import Foundation +#if canImport(Core) + import Core +#endif + +public struct PushTaskRecords: Codable, JSONEncodable { + /// Unique record identifier. + public var objectID: String + + public init(objectID: String) { + self.objectID = objectID + } + + public enum CodingKeys: String, CodingKey, CaseIterable { + case objectID + } + + public var additionalProperties: [String: AnyCodable] = [:] + + public subscript(key: String) -> AnyCodable? { + get { + if let value = additionalProperties[key] { + return value + } + return nil + } + + set { + self.additionalProperties[key] = newValue + } + } + + public init(from dictionary: [String: AnyCodable]) throws { + guard let objectID = dictionary["objectID"]?.value as? String else { + throw GenericError(description: "Failed to cast") + } + self.objectID = objectID + for (key, value) in dictionary { + switch key { + case "objectID": + continue + default: + self.additionalProperties[key] = value + } + } + } + + // Encodable protocol methods + + public func encode(to encoder: Encoder) throws { + var container = encoder.container(keyedBy: CodingKeys.self) + try container.encode(self.objectID, forKey: .objectID) + var additionalPropertiesContainer = encoder.container(keyedBy: String.self) + try additionalPropertiesContainer.encodeMap(self.additionalProperties) + } + + // Decodable protocol methods + + public init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.objectID = try container.decode(String.self, forKey: .objectID) + var nonAdditionalPropertyKeys = Set() + nonAdditionalPropertyKeys.insert("objectID") + let additionalPropertiesContainer = try decoder.container(keyedBy: String.self) + self.additionalProperties = try additionalPropertiesContainer.decodeMap( + AnyCodable.self, + excludedKeys: nonAdditionalPropertyKeys + ) + } +} + +extension PushTaskRecords: Equatable { + public static func ==(lhs: PushTaskRecords, rhs: PushTaskRecords) -> Bool { + lhs.objectID == rhs.objectID + && lhs.additionalProperties == rhs.additionalProperties + } +} + +extension PushTaskRecords: Hashable { + public func hash(into hasher: inout Hasher) { + hasher.combine(self.objectID.hashValue) + hasher.combine(self.additionalProperties.hashValue) + } +}