Skip to content

Commit d27589f

Browse files
feat(specs): add generate code endpoint to ingestion specs (generated)
algolia/api-clients-automation#3489 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 036dcf4 commit d27589f

File tree

3 files changed

+137
-1
lines changed

3 files changed

+137
-1
lines changed

Sources/Ingestion/IngestionClient.swift

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1149,6 +1149,54 @@ open class IngestionClient {
11491149
)
11501150
}
11511151

1152+
/// - parameter generateTransformationCodePayload: (body)
1153+
/// - returns: GenerateTransformationCodeResponse
1154+
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
1155+
open func generateTransformationCode(
1156+
generateTransformationCodePayload: GenerateTransformationCodePayload,
1157+
requestOptions: RequestOptions? = nil
1158+
) async throws -> GenerateTransformationCodeResponse {
1159+
let response: Response<GenerateTransformationCodeResponse> = try await generateTransformationCodeWithHTTPInfo(
1160+
generateTransformationCodePayload: generateTransformationCodePayload,
1161+
requestOptions: requestOptions
1162+
)
1163+
1164+
guard let body = response.body else {
1165+
throw AlgoliaError.missingData
1166+
}
1167+
1168+
return body
1169+
}
1170+
1171+
// Generates code for the selected model based on the given prompt.
1172+
// Required API Key ACLs:
1173+
// - addObject
1174+
// - deleteIndex
1175+
// - editSettings
1176+
//
1177+
// - parameter generateTransformationCodePayload: (body)
1178+
// - returns: RequestBuilder<GenerateTransformationCodeResponse>
1179+
1180+
open func generateTransformationCodeWithHTTPInfo(
1181+
generateTransformationCodePayload: GenerateTransformationCodePayload,
1182+
requestOptions userRequestOptions: RequestOptions? = nil
1183+
) async throws -> Response<GenerateTransformationCodeResponse> {
1184+
let resourcePath = "/1/transformations/models"
1185+
let body = generateTransformationCodePayload
1186+
let queryParameters: [String: Any?]? = nil
1187+
1188+
let nillableHeaders: [String: Any?]? = nil
1189+
1190+
let headers = APIHelper.rejectNilHeaders(nillableHeaders)
1191+
1192+
return try await self.transporter.send(
1193+
method: "POST",
1194+
path: resourcePath,
1195+
data: body,
1196+
requestOptions: RequestOptions(headers: headers, queryParameters: queryParameters) + userRequestOptions
1197+
)
1198+
}
1199+
11521200
/// - parameter authenticationID: (path) Unique identifier of an authentication resource.
11531201
/// - returns: Authentication
11541202
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *)
@@ -2343,7 +2391,7 @@ open class IngestionClient {
23432391
requestOptions userRequestOptions: RequestOptions? =
23442392
nil
23452393
) async throws -> Response<TransformationModels> {
2346-
let resourcePath = "/1/transformations/copilot"
2394+
let resourcePath = "/1/transformations/models"
23472395
let body: AnyCodable? = nil
23482396
let queryParameters: [String: Any?]? = nil
23492397

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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+
public struct GenerateTransformationCodePayload: Codable, JSONEncodable {
10+
public var id: String
11+
public var systemPrompt: String?
12+
public var userPrompt: String
13+
14+
public init(id: String, systemPrompt: String? = nil, userPrompt: String) {
15+
self.id = id
16+
self.systemPrompt = systemPrompt
17+
self.userPrompt = userPrompt
18+
}
19+
20+
public enum CodingKeys: String, CodingKey, CaseIterable {
21+
case id
22+
case systemPrompt
23+
case userPrompt
24+
}
25+
26+
// Encodable protocol methods
27+
28+
public func encode(to encoder: Encoder) throws {
29+
var container = encoder.container(keyedBy: CodingKeys.self)
30+
try container.encode(self.id, forKey: .id)
31+
try container.encodeIfPresent(self.systemPrompt, forKey: .systemPrompt)
32+
try container.encode(self.userPrompt, forKey: .userPrompt)
33+
}
34+
}
35+
36+
extension GenerateTransformationCodePayload: Equatable {
37+
public static func ==(lhs: GenerateTransformationCodePayload, rhs: GenerateTransformationCodePayload) -> Bool {
38+
lhs.id == rhs.id &&
39+
lhs.systemPrompt == rhs.systemPrompt &&
40+
lhs.userPrompt == rhs.userPrompt
41+
}
42+
}
43+
44+
extension GenerateTransformationCodePayload: Hashable {
45+
public func hash(into hasher: inout Hasher) {
46+
hasher.combine(self.id.hashValue)
47+
hasher.combine(self.systemPrompt?.hashValue)
48+
hasher.combine(self.userPrompt.hashValue)
49+
}
50+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
public struct GenerateTransformationCodeResponse: Codable, JSONEncodable {
10+
public var generatedCode: String?
11+
12+
public init(generatedCode: String? = nil) {
13+
self.generatedCode = generatedCode
14+
}
15+
16+
public enum CodingKeys: String, CodingKey, CaseIterable {
17+
case generatedCode
18+
}
19+
20+
// Encodable protocol methods
21+
22+
public func encode(to encoder: Encoder) throws {
23+
var container = encoder.container(keyedBy: CodingKeys.self)
24+
try container.encodeIfPresent(self.generatedCode, forKey: .generatedCode)
25+
}
26+
}
27+
28+
extension GenerateTransformationCodeResponse: Equatable {
29+
public static func ==(lhs: GenerateTransformationCodeResponse, rhs: GenerateTransformationCodeResponse) -> Bool {
30+
lhs.generatedCode == rhs.generatedCode
31+
}
32+
}
33+
34+
extension GenerateTransformationCodeResponse: Hashable {
35+
public func hash(into hasher: inout Hasher) {
36+
hasher.combine(self.generatedCode?.hashValue)
37+
}
38+
}

0 commit comments

Comments
 (0)