Skip to content

Commit 2699e03

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 a1def9f commit 2699e03

File tree

3 files changed

+282
-1
lines changed

3 files changed

+282
-1
lines changed

algoliasearch/Clients/IngestionClient.cs

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,30 @@ public interface IIngestionClient
515515
/// <returns>TaskUpdateResponse</returns>
516516
TaskUpdateResponse EnableTaskV1(string taskID, RequestOptions options = null, CancellationToken cancellationToken = default);
517517

518+
/// <summary>
519+
/// Generates code for the selected model based on the given prompt.
520+
/// </summary>
521+
/// <param name="generateTransformationCodePayload"></param>
522+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
523+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
524+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
525+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
526+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
527+
/// <returns>Task of GenerateTransformationCodeResponse</returns>
528+
Task<GenerateTransformationCodeResponse> GenerateTransformationCodeAsync(GenerateTransformationCodePayload generateTransformationCodePayload, RequestOptions options = null, CancellationToken cancellationToken = default);
529+
530+
/// <summary>
531+
/// Generates code for the selected model based on the given prompt. (Synchronous version)
532+
/// </summary>
533+
/// <param name="generateTransformationCodePayload"></param>
534+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
535+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
536+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
537+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
538+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
539+
/// <returns>GenerateTransformationCodeResponse</returns>
540+
GenerateTransformationCodeResponse GenerateTransformationCode(GenerateTransformationCodePayload generateTransformationCodePayload, RequestOptions options = null, CancellationToken cancellationToken = default);
541+
518542
/// <summary>
519543
/// Retrieves an authentication resource by its ID.
520544
/// </summary>
@@ -2463,6 +2487,54 @@ public TaskUpdateResponse EnableTaskV1(string taskID, RequestOptions options = n
24632487
AsyncHelper.RunSync(() => EnableTaskV1Async(taskID, options, cancellationToken));
24642488

24652489

2490+
/// <summary>
2491+
/// Generates code for the selected model based on the given prompt.
2492+
/// </summary>
2493+
///
2494+
/// Required API Key ACLs:
2495+
/// - addObject
2496+
/// - deleteIndex
2497+
/// - editSettings
2498+
/// <param name="generateTransformationCodePayload"></param>
2499+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
2500+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
2501+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
2502+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
2503+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
2504+
/// <returns>Task of GenerateTransformationCodeResponse</returns>
2505+
public async Task<GenerateTransformationCodeResponse> GenerateTransformationCodeAsync(GenerateTransformationCodePayload generateTransformationCodePayload, RequestOptions options = null, CancellationToken cancellationToken = default)
2506+
{
2507+
2508+
if (generateTransformationCodePayload == null)
2509+
throw new ArgumentException("Parameter `generateTransformationCodePayload` is required when calling `GenerateTransformationCode`.");
2510+
2511+
var requestOptions = new InternalRequestOptions(options);
2512+
2513+
2514+
requestOptions.Data = generateTransformationCodePayload;
2515+
return await _transport.ExecuteRequestAsync<GenerateTransformationCodeResponse>(new HttpMethod("POST"), "/1/transformations/models", requestOptions, cancellationToken).ConfigureAwait(false);
2516+
}
2517+
2518+
2519+
/// <summary>
2520+
/// Generates code for the selected model based on the given prompt. (Synchronous version)
2521+
/// </summary>
2522+
///
2523+
/// Required API Key ACLs:
2524+
/// - addObject
2525+
/// - deleteIndex
2526+
/// - editSettings
2527+
/// <param name="generateTransformationCodePayload"></param>
2528+
/// <param name="options">Add extra http header or query parameters to Algolia.</param>
2529+
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
2530+
/// <exception cref="ArgumentException">Thrown when arguments are not correct</exception>
2531+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaApiException">Thrown when the API call was rejected by Algolia</exception>
2532+
/// <exception cref="Algolia.Search.Exceptions.AlgoliaUnreachableHostException">Thrown when the client failed to call the endpoint</exception>
2533+
/// <returns>GenerateTransformationCodeResponse</returns>
2534+
public GenerateTransformationCodeResponse GenerateTransformationCode(GenerateTransformationCodePayload generateTransformationCodePayload, RequestOptions options = null, CancellationToken cancellationToken = default) =>
2535+
AsyncHelper.RunSync(() => GenerateTransformationCodeAsync(generateTransformationCodePayload, options, cancellationToken));
2536+
2537+
24662538
/// <summary>
24672539
/// Retrieves an authentication resource by its ID.
24682540
/// </summary>
@@ -3323,7 +3395,7 @@ public async Task<TransformationModels> ListTransformationModelsAsync(RequestOpt
33233395
var requestOptions = new InternalRequestOptions(options);
33243396

33253397

3326-
return await _transport.ExecuteRequestAsync<TransformationModels>(new HttpMethod("GET"), "/1/transformations/copilot", requestOptions, cancellationToken).ConfigureAwait(false);
3398+
return await _transport.ExecuteRequestAsync<TransformationModels>(new HttpMethod("GET"), "/1/transformations/models", requestOptions, cancellationToken).ConfigureAwait(false);
33273399
}
33283400

33293401

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Ingestion;
13+
14+
/// <summary>
15+
/// GenerateTransformationCodePayload
16+
/// </summary>
17+
public partial class GenerateTransformationCodePayload
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the GenerateTransformationCodePayload class.
21+
/// </summary>
22+
[JsonConstructor]
23+
public GenerateTransformationCodePayload() { }
24+
/// <summary>
25+
/// Initializes a new instance of the GenerateTransformationCodePayload class.
26+
/// </summary>
27+
/// <param name="id">id (required).</param>
28+
/// <param name="userPrompt">userPrompt (required).</param>
29+
public GenerateTransformationCodePayload(string id, string userPrompt)
30+
{
31+
Id = id ?? throw new ArgumentNullException(nameof(id));
32+
UserPrompt = userPrompt ?? throw new ArgumentNullException(nameof(userPrompt));
33+
}
34+
35+
/// <summary>
36+
/// Gets or Sets Id
37+
/// </summary>
38+
[JsonPropertyName("id")]
39+
public string Id { get; set; }
40+
41+
/// <summary>
42+
/// Gets or Sets SystemPrompt
43+
/// </summary>
44+
[JsonPropertyName("systemPrompt")]
45+
public string SystemPrompt { get; set; }
46+
47+
/// <summary>
48+
/// Gets or Sets UserPrompt
49+
/// </summary>
50+
[JsonPropertyName("userPrompt")]
51+
public string UserPrompt { get; set; }
52+
53+
/// <summary>
54+
/// Returns the string presentation of the object
55+
/// </summary>
56+
/// <returns>String presentation of the object</returns>
57+
public override string ToString()
58+
{
59+
StringBuilder sb = new StringBuilder();
60+
sb.Append("class GenerateTransformationCodePayload {\n");
61+
sb.Append(" Id: ").Append(Id).Append("\n");
62+
sb.Append(" SystemPrompt: ").Append(SystemPrompt).Append("\n");
63+
sb.Append(" UserPrompt: ").Append(UserPrompt).Append("\n");
64+
sb.Append("}\n");
65+
return sb.ToString();
66+
}
67+
68+
/// <summary>
69+
/// Returns the JSON string presentation of the object
70+
/// </summary>
71+
/// <returns>JSON string presentation of the object</returns>
72+
public virtual string ToJson()
73+
{
74+
return JsonSerializer.Serialize(this, JsonConfig.Options);
75+
}
76+
77+
/// <summary>
78+
/// Returns true if objects are equal
79+
/// </summary>
80+
/// <param name="obj">Object to be compared</param>
81+
/// <returns>Boolean</returns>
82+
public override bool Equals(object obj)
83+
{
84+
if (obj is not GenerateTransformationCodePayload input)
85+
{
86+
return false;
87+
}
88+
89+
return
90+
(Id == input.Id || (Id != null && Id.Equals(input.Id))) &&
91+
(SystemPrompt == input.SystemPrompt || (SystemPrompt != null && SystemPrompt.Equals(input.SystemPrompt))) &&
92+
(UserPrompt == input.UserPrompt || (UserPrompt != null && UserPrompt.Equals(input.UserPrompt)));
93+
}
94+
95+
/// <summary>
96+
/// Gets the hash code
97+
/// </summary>
98+
/// <returns>Hash code</returns>
99+
public override int GetHashCode()
100+
{
101+
unchecked // Overflow is fine, just wrap
102+
{
103+
int hashCode = 41;
104+
if (Id != null)
105+
{
106+
hashCode = (hashCode * 59) + Id.GetHashCode();
107+
}
108+
if (SystemPrompt != null)
109+
{
110+
hashCode = (hashCode * 59) + SystemPrompt.GetHashCode();
111+
}
112+
if (UserPrompt != null)
113+
{
114+
hashCode = (hashCode * 59) + UserPrompt.GetHashCode();
115+
}
116+
return hashCode;
117+
}
118+
}
119+
120+
}
121+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
//
2+
// 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.
3+
//
4+
using System;
5+
using System.Text;
6+
using System.Linq;
7+
using System.Text.Json.Serialization;
8+
using System.Collections.Generic;
9+
using Algolia.Search.Serializer;
10+
using System.Text.Json;
11+
12+
namespace Algolia.Search.Models.Ingestion;
13+
14+
/// <summary>
15+
/// GenerateTransformationCodeResponse
16+
/// </summary>
17+
public partial class GenerateTransformationCodeResponse
18+
{
19+
/// <summary>
20+
/// Initializes a new instance of the GenerateTransformationCodeResponse class.
21+
/// </summary>
22+
public GenerateTransformationCodeResponse()
23+
{
24+
}
25+
26+
/// <summary>
27+
/// Gets or Sets GeneratedCode
28+
/// </summary>
29+
[JsonPropertyName("generatedCode")]
30+
public string GeneratedCode { get; set; }
31+
32+
/// <summary>
33+
/// Returns the string presentation of the object
34+
/// </summary>
35+
/// <returns>String presentation of the object</returns>
36+
public override string ToString()
37+
{
38+
StringBuilder sb = new StringBuilder();
39+
sb.Append("class GenerateTransformationCodeResponse {\n");
40+
sb.Append(" GeneratedCode: ").Append(GeneratedCode).Append("\n");
41+
sb.Append("}\n");
42+
return sb.ToString();
43+
}
44+
45+
/// <summary>
46+
/// Returns the JSON string presentation of the object
47+
/// </summary>
48+
/// <returns>JSON string presentation of the object</returns>
49+
public virtual string ToJson()
50+
{
51+
return JsonSerializer.Serialize(this, JsonConfig.Options);
52+
}
53+
54+
/// <summary>
55+
/// Returns true if objects are equal
56+
/// </summary>
57+
/// <param name="obj">Object to be compared</param>
58+
/// <returns>Boolean</returns>
59+
public override bool Equals(object obj)
60+
{
61+
if (obj is not GenerateTransformationCodeResponse input)
62+
{
63+
return false;
64+
}
65+
66+
return
67+
(GeneratedCode == input.GeneratedCode || (GeneratedCode != null && GeneratedCode.Equals(input.GeneratedCode)));
68+
}
69+
70+
/// <summary>
71+
/// Gets the hash code
72+
/// </summary>
73+
/// <returns>Hash code</returns>
74+
public override int GetHashCode()
75+
{
76+
unchecked // Overflow is fine, just wrap
77+
{
78+
int hashCode = 41;
79+
if (GeneratedCode != null)
80+
{
81+
hashCode = (hashCode * 59) + GeneratedCode.GetHashCode();
82+
}
83+
return hashCode;
84+
}
85+
}
86+
87+
}
88+

0 commit comments

Comments
 (0)