Skip to content

Commit 75d7a73

Browse files
feat(specs): update transformation specs for no-code (generated)
algolia/api-clients-automation#4901 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Mehmet Ali Gok <[email protected]>
1 parent 57691d9 commit 75d7a73

File tree

7 files changed

+189
-7
lines changed

7 files changed

+189
-7
lines changed

Sources/Ingestion/Models/Transformation.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,11 @@ public struct Transformation: Codable, JSONEncodable {
1111
public var transformationID: String
1212
/// The authentications associated with the current transformation.
1313
public var authenticationIDs: [String]?
14-
/// The source code of the transformation.
14+
/// It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
15+
@available(*, deprecated, message: "This property is deprecated.")
1516
public var code: String
17+
public var type: TransformationType?
18+
public var input: TransformationInput?
1619
/// The uniquely identified name of your transformation.
1720
public var name: String
1821
/// A descriptive name for your transformation of what it does.
@@ -28,6 +31,8 @@ public struct Transformation: Codable, JSONEncodable {
2831
transformationID: String,
2932
authenticationIDs: [String]? = nil,
3033
code: String,
34+
type: TransformationType? = nil,
35+
input: TransformationInput? = nil,
3136
name: String,
3237
description: String? = nil,
3338
owner: String? = nil,
@@ -37,6 +42,8 @@ public struct Transformation: Codable, JSONEncodable {
3742
self.transformationID = transformationID
3843
self.authenticationIDs = authenticationIDs
3944
self.code = code
45+
self.type = type
46+
self.input = input
4047
self.name = name
4148
self.description = description
4249
self.owner = owner
@@ -48,6 +55,8 @@ public struct Transformation: Codable, JSONEncodable {
4855
case transformationID
4956
case authenticationIDs
5057
case code
58+
case type
59+
case input
5160
case name
5261
case description
5362
case owner
@@ -62,6 +71,8 @@ public struct Transformation: Codable, JSONEncodable {
6271
try container.encode(self.transformationID, forKey: .transformationID)
6372
try container.encodeIfPresent(self.authenticationIDs, forKey: .authenticationIDs)
6473
try container.encode(self.code, forKey: .code)
74+
try container.encodeIfPresent(self.type, forKey: .type)
75+
try container.encodeIfPresent(self.input, forKey: .input)
6576
try container.encode(self.name, forKey: .name)
6677
try container.encodeIfPresent(self.description, forKey: .description)
6778
try container.encodeIfPresent(self.owner, forKey: .owner)
@@ -75,6 +86,8 @@ extension Transformation: Equatable {
7586
lhs.transformationID == rhs.transformationID &&
7687
lhs.authenticationIDs == rhs.authenticationIDs &&
7788
lhs.code == rhs.code &&
89+
lhs.type == rhs.type &&
90+
lhs.input == rhs.input &&
7891
lhs.name == rhs.name &&
7992
lhs.description == rhs.description &&
8093
lhs.owner == rhs.owner &&
@@ -88,6 +101,8 @@ extension Transformation: Hashable {
88101
hasher.combine(self.transformationID.hashValue)
89102
hasher.combine(self.authenticationIDs?.hashValue)
90103
hasher.combine(self.code.hashValue)
104+
hasher.combine(self.type?.hashValue)
105+
hasher.combine(self.input?.hashValue)
91106
hasher.combine(self.name.hashValue)
92107
hasher.combine(self.description?.hashValue)
93108
hasher.combine(self.owner?.hashValue)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+
/// Input for a transformation that contains the source code of the transformation.
10+
public struct TransformationCode: Codable, JSONEncodable {
11+
/// The source code of the transformation.
12+
public var code: String
13+
14+
public init(code: String) {
15+
self.code = code
16+
}
17+
18+
public enum CodingKeys: String, CodingKey, CaseIterable {
19+
case code
20+
}
21+
22+
// Encodable protocol methods
23+
24+
public func encode(to encoder: Encoder) throws {
25+
var container = encoder.container(keyedBy: CodingKeys.self)
26+
try container.encode(self.code, forKey: .code)
27+
}
28+
}
29+
30+
extension TransformationCode: Equatable {
31+
public static func ==(lhs: TransformationCode, rhs: TransformationCode) -> Bool {
32+
lhs.code == rhs.code
33+
}
34+
}
35+
36+
extension TransformationCode: Hashable {
37+
public func hash(into hasher: inout Hasher) {
38+
hasher.combine(self.code.hashValue)
39+
}
40+
}

Sources/Ingestion/Models/TransformationCreate.swift

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,39 @@ import Foundation
88

99
/// API request body for creating a transformation.
1010
public struct TransformationCreate: Codable, JSONEncodable {
11-
/// The source code of the transformation.
12-
public var code: String
11+
/// It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
12+
@available(*, deprecated, message: "This property is deprecated.")
13+
public var code: String?
1314
/// The uniquely identified name of your transformation.
1415
public var name: String
16+
public var type: TransformationType
17+
public var input: TransformationInput
1518
/// A descriptive name for your transformation of what it does.
1619
public var description: String?
1720
/// The authentications associated with the current transformation.
1821
public var authenticationIDs: [String]?
1922

20-
public init(code: String, name: String, description: String? = nil, authenticationIDs: [String]? = nil) {
23+
public init(
24+
code: String? = nil,
25+
name: String,
26+
type: TransformationType,
27+
input: TransformationInput,
28+
description: String? = nil,
29+
authenticationIDs: [String]? = nil
30+
) {
2131
self.code = code
2232
self.name = name
33+
self.type = type
34+
self.input = input
2335
self.description = description
2436
self.authenticationIDs = authenticationIDs
2537
}
2638

2739
public enum CodingKeys: String, CodingKey, CaseIterable {
2840
case code
2941
case name
42+
case type
43+
case input
3044
case description
3145
case authenticationIDs
3246
}
@@ -35,8 +49,10 @@ public struct TransformationCreate: Codable, JSONEncodable {
3549

3650
public func encode(to encoder: Encoder) throws {
3751
var container = encoder.container(keyedBy: CodingKeys.self)
38-
try container.encode(self.code, forKey: .code)
52+
try container.encodeIfPresent(self.code, forKey: .code)
3953
try container.encode(self.name, forKey: .name)
54+
try container.encode(self.type, forKey: .type)
55+
try container.encode(self.input, forKey: .input)
4056
try container.encodeIfPresent(self.description, forKey: .description)
4157
try container.encodeIfPresent(self.authenticationIDs, forKey: .authenticationIDs)
4258
}
@@ -46,15 +62,19 @@ extension TransformationCreate: Equatable {
4662
public static func ==(lhs: TransformationCreate, rhs: TransformationCreate) -> Bool {
4763
lhs.code == rhs.code &&
4864
lhs.name == rhs.name &&
65+
lhs.type == rhs.type &&
66+
lhs.input == rhs.input &&
4967
lhs.description == rhs.description &&
5068
lhs.authenticationIDs == rhs.authenticationIDs
5169
}
5270
}
5371

5472
extension TransformationCreate: Hashable {
5573
public func hash(into hasher: inout Hasher) {
56-
hasher.combine(self.code.hashValue)
74+
hasher.combine(self.code?.hashValue)
5775
hasher.combine(self.name.hashValue)
76+
hasher.combine(self.type.hashValue)
77+
hasher.combine(self.input.hashValue)
5878
hasher.combine(self.description?.hashValue)
5979
hasher.combine(self.authenticationIDs?.hashValue)
6080
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
/// The input for the transformation, which can be either code or a no-code configuration.
10+
public enum TransformationInput: Codable, JSONEncodable, AbstractEncodable {
11+
case transformationCode(TransformationCode)
12+
case transformationNoCode(TransformationNoCode)
13+
14+
public func encode(to encoder: Encoder) throws {
15+
var container = encoder.singleValueContainer()
16+
switch self {
17+
case let .transformationCode(value):
18+
try container.encode(value)
19+
case let .transformationNoCode(value):
20+
try container.encode(value)
21+
}
22+
}
23+
24+
public init(from decoder: Decoder) throws {
25+
let container = try decoder.singleValueContainer()
26+
if let value = try? container.decode(TransformationCode.self) {
27+
self = .transformationCode(value)
28+
} else if let value = try? container.decode(TransformationNoCode.self) {
29+
self = .transformationNoCode(value)
30+
} else {
31+
throw DecodingError.typeMismatch(
32+
Self.Type.self,
33+
.init(
34+
codingPath: decoder.codingPath,
35+
debugDescription: "Unable to decode instance of TransformationInput"
36+
)
37+
)
38+
}
39+
}
40+
41+
public func GetActualInstance() -> Encodable {
42+
switch self {
43+
case let .transformationCode(value):
44+
value as TransformationCode
45+
case let .transformationNoCode(value):
46+
value as TransformationNoCode
47+
}
48+
}
49+
}
50+
51+
extension TransformationInput: Equatable {}
52+
extension TransformationInput: Hashable {}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
/// Input for a no-code transformation that contains a series of steps.
10+
public struct TransformationNoCode: Codable, JSONEncodable {
11+
public var steps: [AnyCodable]
12+
13+
public init(steps: [AnyCodable]) {
14+
self.steps = steps
15+
}
16+
17+
public enum CodingKeys: String, CodingKey, CaseIterable {
18+
case steps
19+
}
20+
21+
// Encodable protocol methods
22+
23+
public func encode(to encoder: Encoder) throws {
24+
var container = encoder.container(keyedBy: CodingKeys.self)
25+
try container.encode(self.steps, forKey: .steps)
26+
}
27+
}
28+
29+
extension TransformationNoCode: Equatable {
30+
public static func ==(lhs: TransformationNoCode, rhs: TransformationNoCode) -> Bool {
31+
lhs.steps == rhs.steps
32+
}
33+
}
34+
35+
extension TransformationNoCode: Hashable {
36+
public func hash(into hasher: inout Hasher) {
37+
hasher.combine(self.steps.hashValue)
38+
}
39+
}

Sources/Ingestion/Models/TransformationTry.swift

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

99
public struct TransformationTry: Codable, JSONEncodable {
10-
/// The source code of the transformation.
10+
/// It is deprecated. Use the `input` field with proper `type` instead to specify the transformation code.
11+
@available(*, deprecated, message: "This property is deprecated.")
1112
public var code: String
1213
/// The record to apply the given code to.
1314
public var sampleRecord: AnyCodable
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
/// The type of transformation, which can be either 'code' or 'noCode'.
10+
public enum TransformationType: String, Codable, CaseIterable {
11+
case code
12+
case noCode
13+
}
14+
15+
extension TransformationType: Hashable {}

0 commit comments

Comments
 (0)