Skip to content

Commit 407156b

Browse files
feat(specs): add authentications to ingestion transformations (generated)
algolia/api-clients-automation#3494 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 36fcfc9 commit 407156b

File tree

4 files changed

+93
-5
lines changed

4 files changed

+93
-5
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3095,7 +3095,7 @@ open class IngestionClient {
30953095
return body
30963096
}
30973097

3098-
// Try a transformation.
3098+
// Try a transformation before creating it.
30993099
// Required API Key ACLs:
31003100
// - addObject
31013101
// - deleteIndex
@@ -3124,6 +3124,73 @@ open class IngestionClient {
31243124
)
31253125
}
31263126

3127+
/// - parameter transformationID: (path) Unique identifier of a transformation.
3128+
/// - parameter transformationTry: (body)
3129+
/// - returns: TransformationTryResponse
3130+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
3131+
open func tryTransformationBeforeUpdate(
3132+
transformationID: String,
3133+
transformationTry: TransformationTry,
3134+
requestOptions: RequestOptions? = nil
3135+
) async throws -> TransformationTryResponse {
3136+
let response: Response<TransformationTryResponse> = try await tryTransformationBeforeUpdateWithHTTPInfo(
3137+
transformationID: transformationID,
3138+
transformationTry: transformationTry,
3139+
requestOptions: requestOptions
3140+
)
3141+
3142+
guard let body = response.body else {
3143+
throw AlgoliaError.missingData
3144+
}
3145+
3146+
return body
3147+
}
3148+
3149+
// Try a transformation before updating it.
3150+
// Required API Key ACLs:
3151+
// - addObject
3152+
// - deleteIndex
3153+
// - editSettings
3154+
//
3155+
// - parameter transformationID: (path) Unique identifier of a transformation.
3156+
//
3157+
// - parameter transformationTry: (body)
3158+
// - returns: RequestBuilder<TransformationTryResponse>
3159+
3160+
open func tryTransformationBeforeUpdateWithHTTPInfo(
3161+
transformationID: String,
3162+
transformationTry: TransformationTry,
3163+
requestOptions userRequestOptions: RequestOptions? = nil
3164+
) async throws -> Response<TransformationTryResponse> {
3165+
guard !transformationID.isEmpty else {
3166+
throw AlgoliaError.invalidArgument("transformationID", "tryTransformationBeforeUpdate")
3167+
}
3168+
3169+
var resourcePath = "/1/transformations/{transformationID}/try"
3170+
let transformationIDPreEscape = "\(APIHelper.mapValueToPathItem(transformationID))"
3171+
let transformationIDPostEscape = transformationIDPreEscape
3172+
.addingPercentEncoding(withAllowedCharacters: .urlPathAlgoliaAllowed) ?? ""
3173+
resourcePath = resourcePath.replacingOccurrences(
3174+
of: "{transformationID}",
3175+
with: transformationIDPostEscape,
3176+
options: .literal,
3177+
range: nil
3178+
)
3179+
let body = transformationTry
3180+
let queryParameters: [String: Any?]? = nil
3181+
3182+
let nillableHeaders: [String: Any?]? = nil
3183+
3184+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
3185+
3186+
return try await self.transporter.send(
3187+
method: "POST",
3188+
path: resourcePath,
3189+
data: body,
3190+
requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions
3191+
)
3192+
}
3193+
31273194
/// - parameter authenticationID: (path) Unique identifier of an authentication resource.
31283195
/// - parameter authenticationUpdate: (body)
31293196
/// - returns: AuthenticationUpdateResponse

Sources/Ingestion/Models/Transformation.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import Foundation
99
public struct Transformation: Codable, JSONEncodable {
1010
/// Universally unique identifier (UUID) of a transformation.
1111
public var transformationID: String
12+
/// The authentications associated for the current transformation.
13+
public var authenticationIDs: [String]?
1214
/// The source code of the transformation.
1315
public var code: String
1416
/// The uniquely identified name of your transformation.
@@ -22,13 +24,15 @@ public struct Transformation: Codable, JSONEncodable {
2224

2325
public init(
2426
transformationID: String,
27+
authenticationIDs: [String]? = nil,
2528
code: String,
2629
name: String,
2730
description: String? = nil,
2831
createdAt: String,
2932
updatedAt: String? = nil
3033
) {
3134
self.transformationID = transformationID
35+
self.authenticationIDs = authenticationIDs
3236
self.code = code
3337
self.name = name
3438
self.description = description
@@ -38,6 +42,7 @@ public struct Transformation: Codable, JSONEncodable {
3842

3943
public enum CodingKeys: String, CodingKey, CaseIterable {
4044
case transformationID
45+
case authenticationIDs
4146
case code
4247
case name
4348
case description
@@ -50,6 +55,7 @@ public struct Transformation: Codable, JSONEncodable {
5055
public func encode(to encoder: Encoder) throws {
5156
var container = encoder.container(keyedBy: CodingKeys.self)
5257
try container.encode(self.transformationID, forKey: .transformationID)
58+
try container.encodeIfPresent(self.authenticationIDs, forKey: .authenticationIDs)
5359
try container.encode(self.code, forKey: .code)
5460
try container.encode(self.name, forKey: .name)
5561
try container.encodeIfPresent(self.description, forKey: .description)
@@ -61,6 +67,7 @@ public struct Transformation: Codable, JSONEncodable {
6167
extension Transformation: Equatable {
6268
public static func ==(lhs: Transformation, rhs: Transformation) -> Bool {
6369
lhs.transformationID == rhs.transformationID &&
70+
lhs.authenticationIDs == rhs.authenticationIDs &&
6471
lhs.code == rhs.code &&
6572
lhs.name == rhs.name &&
6673
lhs.description == rhs.description &&
@@ -72,6 +79,7 @@ extension Transformation: Equatable {
7279
extension Transformation: Hashable {
7380
public func hash(into hasher: inout Hasher) {
7481
hasher.combine(self.transformationID.hashValue)
82+
hasher.combine(self.authenticationIDs?.hashValue)
7583
hasher.combine(self.code.hashValue)
7684
hasher.combine(self.name.hashValue)
7785
hasher.combine(self.description?.hashValue)

Sources/Ingestion/Models/TransformationCreate.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,21 @@ public struct TransformationCreate: Codable, JSONEncodable {
1414
public var name: String
1515
/// A descriptive name for your transformation of what it does.
1616
public var description: String?
17+
/// The authentications associated for the current transformation.
18+
public var authenticationIDs: [String]?
1719

18-
public init(code: String, name: String, description: String? = nil) {
20+
public init(code: String, name: String, description: String? = nil, authenticationIDs: [String]? = nil) {
1921
self.code = code
2022
self.name = name
2123
self.description = description
24+
self.authenticationIDs = authenticationIDs
2225
}
2326

2427
public enum CodingKeys: String, CodingKey, CaseIterable {
2528
case code
2629
case name
2730
case description
31+
case authenticationIDs
2832
}
2933

3034
// Encodable protocol methods
@@ -34,14 +38,16 @@ public struct TransformationCreate: Codable, JSONEncodable {
3438
try container.encode(self.code, forKey: .code)
3539
try container.encode(self.name, forKey: .name)
3640
try container.encodeIfPresent(self.description, forKey: .description)
41+
try container.encodeIfPresent(self.authenticationIDs, forKey: .authenticationIDs)
3742
}
3843
}
3944

4045
extension TransformationCreate: Equatable {
4146
public static func ==(lhs: TransformationCreate, rhs: TransformationCreate) -> Bool {
4247
lhs.code == rhs.code &&
4348
lhs.name == rhs.name &&
44-
lhs.description == rhs.description
49+
lhs.description == rhs.description &&
50+
lhs.authenticationIDs == rhs.authenticationIDs
4551
}
4652
}
4753

@@ -50,5 +56,6 @@ extension TransformationCreate: Hashable {
5056
hasher.combine(self.code.hashValue)
5157
hasher.combine(self.name.hashValue)
5258
hasher.combine(self.description?.hashValue)
59+
hasher.combine(self.authenticationIDs?.hashValue)
5360
}
5461
}

Sources/Ingestion/Models/TransformationTry.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ public struct TransformationTry: Codable, JSONEncodable {
1111
public var code: String
1212
/// The record to apply the given code to.
1313
public var sampleRecord: AnyCodable
14+
public var authentications: [AuthenticationCreate]?
1415

15-
public init(code: String, sampleRecord: AnyCodable) {
16+
public init(code: String, sampleRecord: AnyCodable, authentications: [AuthenticationCreate]? = nil) {
1617
self.code = code
1718
self.sampleRecord = sampleRecord
19+
self.authentications = authentications
1820
}
1921

2022
public enum CodingKeys: String, CodingKey, CaseIterable {
2123
case code
2224
case sampleRecord
25+
case authentications
2326
}
2427

2528
// Encodable protocol methods
@@ -28,19 +31,22 @@ public struct TransformationTry: Codable, JSONEncodable {
2831
var container = encoder.container(keyedBy: CodingKeys.self)
2932
try container.encode(self.code, forKey: .code)
3033
try container.encode(self.sampleRecord, forKey: .sampleRecord)
34+
try container.encodeIfPresent(self.authentications, forKey: .authentications)
3135
}
3236
}
3337

3438
extension TransformationTry: Equatable {
3539
public static func ==(lhs: TransformationTry, rhs: TransformationTry) -> Bool {
3640
lhs.code == rhs.code &&
37-
lhs.sampleRecord == rhs.sampleRecord
41+
lhs.sampleRecord == rhs.sampleRecord &&
42+
lhs.authentications == rhs.authentications
3843
}
3944
}
4045

4146
extension TransformationTry: Hashable {
4247
public func hash(into hasher: inout Hasher) {
4348
hasher.combine(self.code.hashValue)
4449
hasher.combine(self.sampleRecord.hashValue)
50+
hasher.combine(self.authentications?.hashValue)
4551
}
4652
}

0 commit comments

Comments
 (0)