Skip to content

Commit 2525b8c

Browse files
algolia-botmillotp
andcommitted
feat(specs): only use shortname in the source input [skip-bc] (generated)
algolia/api-clients-automation#4287 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Pierre Millot <[email protected]>
1 parent 0413bf7 commit 2525b8c

File tree

5 files changed

+13
-93
lines changed

5 files changed

+13
-93
lines changed

Sources/Ingestion/Models/DockerImageType.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Ingestion/Models/DockerRegistry.swift

Lines changed: 0 additions & 15 deletions
This file was deleted.

Sources/Ingestion/Models/SourceDocker.swift

Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,65 +7,40 @@ import Foundation
77
#endif
88

99
public struct SourceDocker: Codable, JSONEncodable {
10-
public var imageType: DockerImageType
11-
public var registry: DockerRegistry
12-
/// Docker image name.
10+
/// Shortname of the image, as returned by the referential.
1311
public var image: String
14-
/// Docker image version.
15-
public var version: String?
1612
/// Configuration of the spec.
1713
public var configuration: AnyCodable
1814

19-
public init(
20-
imageType: DockerImageType,
21-
registry: DockerRegistry,
22-
image: String,
23-
version: String? = nil,
24-
configuration: AnyCodable
25-
) {
26-
self.imageType = imageType
27-
self.registry = registry
15+
public init(image: String, configuration: AnyCodable) {
2816
self.image = image
29-
self.version = version
3017
self.configuration = configuration
3118
}
3219

3320
public enum CodingKeys: String, CodingKey, CaseIterable {
34-
case imageType
35-
case registry
3621
case image
37-
case version
3822
case configuration
3923
}
4024

4125
// Encodable protocol methods
4226

4327
public func encode(to encoder: Encoder) throws {
4428
var container = encoder.container(keyedBy: CodingKeys.self)
45-
try container.encode(self.imageType, forKey: .imageType)
46-
try container.encode(self.registry, forKey: .registry)
4729
try container.encode(self.image, forKey: .image)
48-
try container.encodeIfPresent(self.version, forKey: .version)
4930
try container.encode(self.configuration, forKey: .configuration)
5031
}
5132
}
5233

5334
extension SourceDocker: Equatable {
5435
public static func ==(lhs: SourceDocker, rhs: SourceDocker) -> Bool {
55-
lhs.imageType == rhs.imageType &&
56-
lhs.registry == rhs.registry &&
57-
lhs.image == rhs.image &&
58-
lhs.version == rhs.version &&
36+
lhs.image == rhs.image &&
5937
lhs.configuration == rhs.configuration
6038
}
6139
}
6240

6341
extension SourceDocker: Hashable {
6442
public func hash(into hasher: inout Hasher) {
65-
hasher.combine(self.imageType.hashValue)
66-
hasher.combine(self.registry.hashValue)
6743
hasher.combine(self.image.hashValue)
68-
hasher.combine(self.version?.hashValue)
6944
hasher.combine(self.configuration.hashValue)
7045
}
7146
}

Sources/Ingestion/Models/SourceInput.swift

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

99
public enum SourceInput: Codable, JSONEncodable, AbstractEncodable {
10-
case sourceDocker(SourceDocker)
1110
case sourceGA4BigQueryExport(SourceGA4BigQueryExport)
11+
case sourceDocker(SourceDocker)
1212
case sourceCommercetools(SourceCommercetools)
1313
case sourceBigCommerce(SourceBigCommerce)
1414
case sourceBigQuery(SourceBigQuery)
@@ -19,10 +19,10 @@ public enum SourceInput: Codable, JSONEncodable, AbstractEncodable {
1919
public func encode(to encoder: Encoder) throws {
2020
var container = encoder.singleValueContainer()
2121
switch self {
22-
case let .sourceDocker(value):
23-
try container.encode(value)
2422
case let .sourceGA4BigQueryExport(value):
2523
try container.encode(value)
24+
case let .sourceDocker(value):
25+
try container.encode(value)
2626
case let .sourceCommercetools(value):
2727
try container.encode(value)
2828
case let .sourceBigCommerce(value):
@@ -40,10 +40,10 @@ public enum SourceInput: Codable, JSONEncodable, AbstractEncodable {
4040

4141
public init(from decoder: Decoder) throws {
4242
let container = try decoder.singleValueContainer()
43-
if let value = try? container.decode(SourceDocker.self) {
44-
self = .sourceDocker(value)
45-
} else if let value = try? container.decode(SourceGA4BigQueryExport.self) {
43+
if let value = try? container.decode(SourceGA4BigQueryExport.self) {
4644
self = .sourceGA4BigQueryExport(value)
45+
} else if let value = try? container.decode(SourceDocker.self) {
46+
self = .sourceDocker(value)
4747
} else if let value = try? container.decode(SourceCommercetools.self) {
4848
self = .sourceCommercetools(value)
4949
} else if let value = try? container.decode(SourceBigCommerce.self) {
@@ -66,10 +66,10 @@ public enum SourceInput: Codable, JSONEncodable, AbstractEncodable {
6666

6767
public func GetActualInstance() -> Encodable {
6868
switch self {
69-
case let .sourceDocker(value):
70-
value as SourceDocker
7169
case let .sourceGA4BigQueryExport(value):
7270
value as SourceGA4BigQueryExport
71+
case let .sourceDocker(value):
72+
value as SourceDocker
7373
case let .sourceCommercetools(value):
7474
value as SourceCommercetools
7575
case let .sourceBigCommerce(value):

Sources/Ingestion/Models/SourceUpdateDocker.swift

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

99
public struct SourceUpdateDocker: Codable, JSONEncodable {
10-
public var registry: DockerRegistry?
11-
/// Docker image name.
12-
public var image: String?
13-
/// Docker image version.
14-
public var version: String?
1510
/// Configuration of the spec.
1611
public var configuration: AnyCodable
1712

18-
public init(
19-
registry: DockerRegistry? = nil,
20-
image: String? = nil,
21-
version: String? = nil,
22-
configuration: AnyCodable
23-
) {
24-
self.registry = registry
25-
self.image = image
26-
self.version = version
13+
public init(configuration: AnyCodable) {
2714
self.configuration = configuration
2815
}
2916

3017
public enum CodingKeys: String, CodingKey, CaseIterable {
31-
case registry
32-
case image
33-
case version
3418
case configuration
3519
}
3620

3721
// Encodable protocol methods
3822

3923
public func encode(to encoder: Encoder) throws {
4024
var container = encoder.container(keyedBy: CodingKeys.self)
41-
try container.encodeIfPresent(self.registry, forKey: .registry)
42-
try container.encodeIfPresent(self.image, forKey: .image)
43-
try container.encodeIfPresent(self.version, forKey: .version)
4425
try container.encode(self.configuration, forKey: .configuration)
4526
}
4627
}
4728

4829
extension SourceUpdateDocker: Equatable {
4930
public static func ==(lhs: SourceUpdateDocker, rhs: SourceUpdateDocker) -> Bool {
50-
lhs.registry == rhs.registry &&
51-
lhs.image == rhs.image &&
52-
lhs.version == rhs.version &&
53-
lhs.configuration == rhs.configuration
31+
lhs.configuration == rhs.configuration
5432
}
5533
}
5634

5735
extension SourceUpdateDocker: Hashable {
5836
public func hash(into hasher: inout Hasher) {
59-
hasher.combine(self.registry?.hashValue)
60-
hasher.combine(self.image?.hashValue)
61-
hasher.combine(self.version?.hashValue)
6237
hasher.combine(self.configuration.hashValue)
6338
}
6439
}

0 commit comments

Comments
 (0)