Skip to content

Commit f179a53

Browse files
HavenDVgithub-actions[bot]
andauthored
feat: Updated OpenAPI spec (#18)
Co-authored-by: github-actions[bot] <dependabot@bot.com>
1 parent 7f6a698 commit f179a53

15 files changed

Lines changed: 725 additions & 52 deletions
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
2+
#nullable enable
3+
4+
namespace NightfallAI
5+
{
6+
/// <summary>
7+
/// Represents a successful HTTP response with status code and headers.
8+
/// </summary>
9+
public partial class AutoSDKHttpResponse
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
13+
/// </summary>
14+
public AutoSDKHttpResponse(
15+
global::System.Net.HttpStatusCode statusCode,
16+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
17+
: this(
18+
statusCode: statusCode,
19+
headers: headers,
20+
requestUri: null)
21+
{
22+
}
23+
24+
/// <summary>
25+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
26+
/// </summary>
27+
public AutoSDKHttpResponse(
28+
global::System.Net.HttpStatusCode statusCode,
29+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
30+
global::System.Uri? requestUri)
31+
{
32+
StatusCode = statusCode;
33+
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
34+
RequestUri = requestUri;
35+
}
36+
37+
/// <summary>
38+
/// Gets the HTTP status code.
39+
/// </summary>
40+
public global::System.Net.HttpStatusCode StatusCode { get; }
41+
/// <summary>
42+
/// Gets the response headers.
43+
/// </summary>
44+
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }
45+
/// <summary>
46+
/// Gets the final request URI associated with the response.
47+
/// </summary>
48+
public global::System.Uri? RequestUri { get; }
49+
50+
internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> CreateHeaders(
51+
global::System.Net.Http.HttpResponseMessage response)
52+
{
53+
response = response ?? throw new global::System.ArgumentNullException(nameof(response));
54+
55+
var headers = global::System.Linq.Enumerable.ToDictionary(
56+
response.Headers,
57+
static header => header.Key,
58+
static header => (global::System.Collections.Generic.IEnumerable<string>)global::System.Linq.Enumerable.ToArray(header.Value),
59+
global::System.StringComparer.OrdinalIgnoreCase);
60+
61+
if (response.Content?.Headers == null)
62+
{
63+
return headers;
64+
}
65+
66+
foreach (var header in response.Content.Headers)
67+
{
68+
if (headers.TryGetValue(header.Key, out var existingValues))
69+
{
70+
headers[header.Key] = global::System.Linq.Enumerable.ToArray(
71+
global::System.Linq.Enumerable.Concat(existingValues, header.Value));
72+
}
73+
else
74+
{
75+
headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value);
76+
}
77+
}
78+
79+
return headers;
80+
}
81+
}
82+
83+
/// <summary>
84+
/// Represents a successful HTTP response with status code, headers, and body.
85+
/// </summary>
86+
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
87+
{
88+
/// <summary>
89+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
90+
/// </summary>
91+
public AutoSDKHttpResponse(
92+
global::System.Net.HttpStatusCode statusCode,
93+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
94+
T body)
95+
: this(
96+
statusCode: statusCode,
97+
headers: headers,
98+
requestUri: null,
99+
body: body)
100+
{
101+
}
102+
103+
/// <summary>
104+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
105+
/// </summary>
106+
public AutoSDKHttpResponse(
107+
global::System.Net.HttpStatusCode statusCode,
108+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
109+
global::System.Uri? requestUri,
110+
T body)
111+
: base(statusCode, headers, requestUri)
112+
{
113+
Body = body;
114+
}
115+
116+
/// <summary>
117+
/// Gets the response body.
118+
/// </summary>
119+
public T Body { get; }
120+
}
121+
}

src/libs/NightfallAI/Generated/NightfallAI.FileScanningClient.CompleteFileUpload.g.cs

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,25 @@ partial void ProcessCompleteFileUploadResponse(
4848
global::System.Guid fileId,
4949
global::NightfallAI.AutoSDKRequestOptions? requestOptions = default,
5050
global::System.Threading.CancellationToken cancellationToken = default)
51+
{
52+
await CompleteFileUploadAsResponseAsync(
53+
fileId: fileId,
54+
requestOptions: requestOptions,
55+
cancellationToken: cancellationToken
56+
).ConfigureAwait(false);
57+
}
58+
/// <summary>
59+
/// Complete a file upload<br/>
60+
/// Marks a file upload session as complete after all chunks have been uploaded.
61+
/// </summary>
62+
/// <param name="fileId"></param>
63+
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
64+
/// <param name="cancellationToken">The token to cancel the operation with</param>
65+
/// <exception cref="global::NightfallAI.ApiException"></exception>
66+
public async global::System.Threading.Tasks.Task<global::NightfallAI.AutoSDKHttpResponse> CompleteFileUploadAsResponseAsync(
67+
global::System.Guid fileId,
68+
global::NightfallAI.AutoSDKRequestOptions? requestOptions = default,
69+
global::System.Threading.CancellationToken cancellationToken = default)
5170
{
5271
PrepareArguments(
5372
client: HttpClient);
@@ -77,6 +96,7 @@ partial void ProcessCompleteFileUploadResponse(
7796

7897
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
7998
{
99+
80100
var __pathBuilder = new global::NightfallAI.PathBuilder(
81101
path: $"/v3/upload/{fileId}/finish",
82102
baseUri: HttpClient.BaseAddress);
@@ -150,6 +170,8 @@ partial void ProcessCompleteFileUploadResponse(
150170
attempt: __attempt,
151171
maxAttempts: __maxAttempts,
152172
willRetry: false,
173+
retryDelay: null,
174+
retryReason: global::System.String.Empty,
153175
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
154176
try
155177
{
@@ -160,6 +182,11 @@ partial void ProcessCompleteFileUploadResponse(
160182
}
161183
catch (global::System.Net.Http.HttpRequestException __exception)
162184
{
185+
var __retryDelay = global::NightfallAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
186+
clientOptions: Options,
187+
requestOptions: requestOptions,
188+
response: null,
189+
attempt: __attempt);
163190
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
164191
await global::NightfallAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
165192
clientOptions: Options,
@@ -177,6 +204,8 @@ partial void ProcessCompleteFileUploadResponse(
177204
attempt: __attempt,
178205
maxAttempts: __maxAttempts,
179206
willRetry: __willRetry,
207+
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
208+
retryReason: "exception",
180209
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
181210
if (!__willRetry)
182211
{
@@ -186,8 +215,7 @@ partial void ProcessCompleteFileUploadResponse(
186215
__httpRequest.Dispose();
187216
__httpRequest = null;
188217
await global::NightfallAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
189-
clientOptions: Options,
190-
requestOptions: requestOptions,
218+
retryDelay: __retryDelay,
191219
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
192220
continue;
193221
}
@@ -196,6 +224,11 @@ partial void ProcessCompleteFileUploadResponse(
196224
__attempt < __maxAttempts &&
197225
global::NightfallAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
198226
{
227+
var __retryDelay = global::NightfallAI.AutoSDKRequestOptionsSupport.GetRetryDelay(
228+
clientOptions: Options,
229+
requestOptions: requestOptions,
230+
response: __response,
231+
attempt: __attempt);
199232
await global::NightfallAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
200233
clientOptions: Options,
201234
context: global::NightfallAI.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -212,14 +245,15 @@ partial void ProcessCompleteFileUploadResponse(
212245
attempt: __attempt,
213246
maxAttempts: __maxAttempts,
214247
willRetry: true,
248+
retryDelay: __retryDelay,
249+
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
215250
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
216251
__response.Dispose();
217252
__response = null;
218253
__httpRequest.Dispose();
219254
__httpRequest = null;
220255
await global::NightfallAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
221-
clientOptions: Options,
222-
requestOptions: requestOptions,
256+
retryDelay: __retryDelay,
223257
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
224258
continue;
225259
}
@@ -259,6 +293,8 @@ partial void ProcessCompleteFileUploadResponse(
259293
attempt: __attemptNumber,
260294
maxAttempts: __maxAttempts,
261295
willRetry: false,
296+
retryDelay: null,
297+
retryReason: global::System.String.Empty,
262298
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
263299
}
264300
else
@@ -279,6 +315,8 @@ partial void ProcessCompleteFileUploadResponse(
279315
attempt: __attemptNumber,
280316
maxAttempts: __maxAttempts,
281317
willRetry: false,
318+
retryDelay: null,
319+
retryReason: global::System.String.Empty,
282320
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
283321
}
284322
// Bad request
@@ -451,6 +489,10 @@ partial void ProcessCompleteFileUploadResponse(
451489
{
452490
__response.EnsureSuccessStatusCode();
453491

492+
return new global::NightfallAI.AutoSDKHttpResponse(
493+
statusCode: __response.StatusCode,
494+
headers: global::NightfallAI.AutoSDKHttpResponse.CreateHeaders(__response),
495+
requestUri: __response.RequestMessage?.RequestUri);
454496
}
455497
catch (global::System.Exception __ex)
456498
{
@@ -472,6 +514,10 @@ partial void ProcessCompleteFileUploadResponse(
472514
try
473515
{
474516
__response.EnsureSuccessStatusCode();
517+
return new global::NightfallAI.AutoSDKHttpResponse(
518+
statusCode: __response.StatusCode,
519+
headers: global::NightfallAI.AutoSDKHttpResponse.CreateHeaders(__response),
520+
requestUri: __response.RequestMessage?.RequestUri);
475521
}
476522
catch (global::System.Exception __ex)
477523
{

0 commit comments

Comments
 (0)