Skip to content

Commit

Permalink
fix(specs): ingestion push task payload [skip-bc] (generated)
Browse files Browse the repository at this point in the history
algolia/api-clients-automation#3607

Co-authored-by: algolia-bot <[email protected]>
Co-authored-by: Clément Vannicatte <[email protected]>
Co-authored-by: Pierre Millot <[email protected]>
  • Loading branch information
3 people committed Aug 29, 2024
1 parent 7d447a8 commit 6e7c5a6
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 57 deletions.
12 changes: 6 additions & 6 deletions Sources/Ingestion/IngestionClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<RunResponse> = try await pushTaskWithHTTPInfo(
taskID: taskID,
batchWriteParams: batchWriteParams,
pushTaskPayload: pushTaskPayload,
requestOptions: requestOptions
)

Expand All @@ -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<RunResponse>

open func pushTaskWithHTTPInfo(
taskID: String,
batchWriteParams: IngestionBatchWriteParams,
pushTaskPayload: PushTaskPayload,
requestOptions userRequestOptions: RequestOptions? = nil
) async throws -> Response<RunResponse> {
guard !taskID.isEmpty else {
Expand All @@ -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
Expand Down
39 changes: 0 additions & 39 deletions Sources/Ingestion/Models/IngestionBatchWriteParams.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,39 @@ 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

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)
}
}
88 changes: 88 additions & 0 deletions Sources/Ingestion/Models/PushTaskRecords.swift
Original file line number Diff line number Diff line change
@@ -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<String>()
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)
}
}

0 comments on commit 6e7c5a6

Please sign in to comment.