Skip to content

Commit 4b639c7

Browse files
committed
Merge branch 'main' of https://github.com/tryAGI/MiniMax
2 parents cadbcfa + 8777947 commit 4b639c7

59 files changed

Lines changed: 2359 additions & 114 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
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 MiniMax
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/MiniMax/Generated/MiniMax.FilesClient.DeleteFile.g.cs

Lines changed: 58 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,29 @@ partial void ProcessDeleteFileResponseContent(
6464
/// <exception cref="global::MiniMax.ApiException"></exception>
6565
public async global::System.Threading.Tasks.Task<global::MiniMax.FileDeleteResponse> DeleteFileAsync(
6666

67+
global::MiniMax.FileDeleteRequest request,
68+
global::MiniMax.AutoSDKRequestOptions? requestOptions = default,
69+
global::System.Threading.CancellationToken cancellationToken = default)
70+
{
71+
var __response = await DeleteFileAsResponseAsync(
72+
73+
request: request,
74+
requestOptions: requestOptions,
75+
cancellationToken: cancellationToken
76+
).ConfigureAwait(false);
77+
78+
return __response.Body;
79+
}
80+
/// <summary>
81+
/// Delete a file.<br/>
82+
/// Deletes a previously uploaded file.
83+
/// </summary>
84+
/// <param name="request"></param>
85+
/// <param name="requestOptions">Per-request overrides such as headers, query parameters, timeout, retries, and response buffering.</param>
86+
/// <param name="cancellationToken">The token to cancel the operation with</param>
87+
/// <exception cref="global::MiniMax.ApiException"></exception>
88+
public async global::System.Threading.Tasks.Task<global::MiniMax.AutoSDKHttpResponse<global::MiniMax.FileDeleteResponse>> DeleteFileAsResponseAsync(
89+
6790
global::MiniMax.FileDeleteRequest request,
6891
global::MiniMax.AutoSDKRequestOptions? requestOptions = default,
6992
global::System.Threading.CancellationToken cancellationToken = default)
@@ -98,6 +121,7 @@ partial void ProcessDeleteFileResponseContent(
98121

99122
global::System.Net.Http.HttpRequestMessage __CreateHttpRequest()
100123
{
124+
101125
var __pathBuilder = new global::MiniMax.PathBuilder(
102126
path: "/v1/files/delete",
103127
baseUri: ResolveBaseUri(
@@ -179,6 +203,8 @@ partial void ProcessDeleteFileResponseContent(
179203
attempt: __attempt,
180204
maxAttempts: __maxAttempts,
181205
willRetry: false,
206+
retryDelay: null,
207+
retryReason: global::System.String.Empty,
182208
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
183209
try
184210
{
@@ -189,6 +215,11 @@ partial void ProcessDeleteFileResponseContent(
189215
}
190216
catch (global::System.Net.Http.HttpRequestException __exception)
191217
{
218+
var __retryDelay = global::MiniMax.AutoSDKRequestOptionsSupport.GetRetryDelay(
219+
clientOptions: Options,
220+
requestOptions: requestOptions,
221+
response: null,
222+
attempt: __attempt);
192223
var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested;
193224
await global::MiniMax.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
194225
clientOptions: Options,
@@ -206,6 +237,8 @@ partial void ProcessDeleteFileResponseContent(
206237
attempt: __attempt,
207238
maxAttempts: __maxAttempts,
208239
willRetry: __willRetry,
240+
retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null,
241+
retryReason: "exception",
209242
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
210243
if (!__willRetry)
211244
{
@@ -215,8 +248,7 @@ partial void ProcessDeleteFileResponseContent(
215248
__httpRequest.Dispose();
216249
__httpRequest = null;
217250
await global::MiniMax.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
218-
clientOptions: Options,
219-
requestOptions: requestOptions,
251+
retryDelay: __retryDelay,
220252
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
221253
continue;
222254
}
@@ -225,6 +257,11 @@ partial void ProcessDeleteFileResponseContent(
225257
__attempt < __maxAttempts &&
226258
global::MiniMax.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode))
227259
{
260+
var __retryDelay = global::MiniMax.AutoSDKRequestOptionsSupport.GetRetryDelay(
261+
clientOptions: Options,
262+
requestOptions: requestOptions,
263+
response: __response,
264+
attempt: __attempt);
228265
await global::MiniMax.AutoSDKRequestOptionsSupport.OnAfterErrorAsync(
229266
clientOptions: Options,
230267
context: global::MiniMax.AutoSDKRequestOptionsSupport.CreateHookContext(
@@ -241,14 +278,15 @@ partial void ProcessDeleteFileResponseContent(
241278
attempt: __attempt,
242279
maxAttempts: __maxAttempts,
243280
willRetry: true,
281+
retryDelay: __retryDelay,
282+
retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture),
244283
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
245284
__response.Dispose();
246285
__response = null;
247286
__httpRequest.Dispose();
248287
__httpRequest = null;
249288
await global::MiniMax.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync(
250-
clientOptions: Options,
251-
requestOptions: requestOptions,
289+
retryDelay: __retryDelay,
252290
cancellationToken: __effectiveCancellationToken).ConfigureAwait(false);
253291
continue;
254292
}
@@ -288,6 +326,8 @@ partial void ProcessDeleteFileResponseContent(
288326
attempt: __attemptNumber,
289327
maxAttempts: __maxAttempts,
290328
willRetry: false,
329+
retryDelay: null,
330+
retryReason: global::System.String.Empty,
291331
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
292332
}
293333
else
@@ -308,6 +348,8 @@ partial void ProcessDeleteFileResponseContent(
308348
attempt: __attemptNumber,
309349
maxAttempts: __maxAttempts,
310350
willRetry: false,
351+
retryDelay: null,
352+
retryReason: global::System.String.Empty,
311353
cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false);
312354
}
313355

@@ -332,9 +374,13 @@ partial void ProcessDeleteFileResponseContent(
332374
{
333375
__response.EnsureSuccessStatusCode();
334376

335-
return
336-
global::MiniMax.FileDeleteResponse.FromJson(__content, JsonSerializerContext) ??
377+
var __value = global::MiniMax.FileDeleteResponse.FromJson(__content, JsonSerializerContext) ??
337378
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
379+
return new global::MiniMax.AutoSDKHttpResponse<global::MiniMax.FileDeleteResponse>(
380+
statusCode: __response.StatusCode,
381+
headers: global::MiniMax.AutoSDKHttpResponse.CreateHeaders(__response),
382+
requestUri: __response.RequestMessage?.RequestUri,
383+
body: __value);
338384
}
339385
catch (global::System.Exception __ex)
340386
{
@@ -362,9 +408,13 @@ partial void ProcessDeleteFileResponseContent(
362408
#endif
363409
).ConfigureAwait(false);
364410

365-
return
366-
await global::MiniMax.FileDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
411+
var __value = await global::MiniMax.FileDeleteResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
367412
throw new global::System.InvalidOperationException("Response deserialization failed.");
413+
return new global::MiniMax.AutoSDKHttpResponse<global::MiniMax.FileDeleteResponse>(
414+
statusCode: __response.StatusCode,
415+
headers: global::MiniMax.AutoSDKHttpResponse.CreateHeaders(__response),
416+
requestUri: __response.RequestMessage?.RequestUri,
417+
body: __value);
368418
}
369419
catch (global::System.Exception __ex)
370420
{

0 commit comments

Comments
 (0)