diff --git a/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.ReingestAllStores.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.ReingestAllStores.g.cs index 5e0c655..22efbd3 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.ReingestAllStores.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.ReingestAllStores.g.cs @@ -14,6 +14,7 @@ public partial class AdminClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -62,6 +63,7 @@ partial void ProcessReingestAllStoresResponseContent( /// Whether the reingestion is billable to the user
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ReingestAllStoresAsync( @@ -69,6 +71,7 @@ partial void ProcessReingestAllStoresResponseContent( string storeIdentifier, global::System.Collections.Generic.IList? statuses = default, bool? billable = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -86,26 +89,47 @@ partial void ProcessReingestAllStoresResponseContent( securityRequirements: s_ReingestAllStoresSecurityRequirements, operationName: "ReingestAllStoresAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("statuses", statuses?.ToString()) - .AddOptionalParameter("billable", billable?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("statuses", statuses?.ToString()) + .AddOptionalParameter("billable", billable?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -115,149 +139,308 @@ partial void ProcessReingestAllStoresResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareReingestAllStoresRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - organizationId: organizationId, - storeIdentifier: storeIdentifier, - statuses: statuses, - billable: billable); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareReingestAllStoresRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + organizationId: organizationId, + storeIdentifier: storeIdentifier, + statuses: statuses, + billable: billable); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessReingestAllStoresResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ReingestAllStores", + methodName: "ReingestAllStoresAsync", + pathTemplate: "$\"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ReingestAllStores", + methodName: "ReingestAllStoresAsync", + pathTemplate: "$\"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ReingestAllStores", + methodName: "ReingestAllStoresAsync", + pathTemplate: "$\"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessReingestAllStoresResponseContent( + response: __response); + ProcessReingestAllStoresResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ReingestAllStores", + methodName: "ReingestAllStoresAsync", + pathTemplate: "$\"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ReingestAllStores", + methodName: "ReingestAllStoresAsync", + pathTemplate: "$\"/v1/admin/stores/{organizationId}/{storeIdentifier}/reingest\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessReingestAllStoresResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.g.cs index f4aed91..03521df 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.AdminClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class AdminClient : global::Mixedbread.IAdminClient, globa #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public AdminClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the AdminClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public AdminClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.CreateApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.CreateApiKey.g.cs index 1cc5a4e..df6fafb 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.CreateApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.CreateApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateApiKeyResponseContent( /// ApiKeyCreated: The response containing the details of the created API key. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateApiKeyAsync( global::Mixedbread.ApiKeyCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateApiKeyResponseContent( securityRequirements: s_CreateApiKeySecurityRequirements, operationName: "CreateApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/api-keys", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/api-keys", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateApiKey", + methodName: "CreateApiKeyAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateApiKey", + methodName: "CreateApiKeyAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateApiKey", + methodName: "CreateApiKeyAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateApiKeyResponseContent( + response: __response); + ProcessCreateApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKeyCreated.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateApiKey", + methodName: "CreateApiKeyAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateApiKey", + methodName: "CreateApiKeyAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKeyCreated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKeyCreated.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKeyCreated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create API key
@@ -264,12 +447,14 @@ partial void ProcessCreateApiKeyResponseContent( /// /// Optional expiration datetime /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateApiKeyAsync( string? name = default, global::System.Collections.Generic.IList? scope = default, global::System.DateTime? expiresAt = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.ApiKeyCreateParams @@ -281,6 +466,7 @@ partial void ProcessCreateApiKeyResponseContent( return await CreateApiKeyAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.DeleteApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.DeleteApiKey.g.cs index f8bca9e..f7464f1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.DeleteApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.DeleteApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDeleteApiKeyResponseContent( /// /// The ID of the API key to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDeleteApiKeyResponseContent( securityRequirements: s_DeleteApiKeySecurityRequirements, operationName: "DeleteApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/api-keys/{apiKeyId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/api-keys/{apiKeyId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessDeleteApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - apiKeyId: apiKeyId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + apiKeyId: apiKeyId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteApiKey", + methodName: "DeleteApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteApiKey", + methodName: "DeleteApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteApiKey", + methodName: "DeleteApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteApiKeyResponseContent( + response: __response); + ProcessDeleteApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKeyDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteApiKey", + methodName: "DeleteApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteApiKey", + methodName: "DeleteApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKeyDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKeyDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKeyDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.ListApiKeys.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.ListApiKeys.g.cs index c7a3906..75db378 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.ListApiKeys.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.ListApiKeys.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -58,11 +59,13 @@ partial void ProcessListApiKeysResponseContent( /// Offset of the first item to return
/// Default Value: 0 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListApiKeysAsync( int? limit = default, int? offset = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -78,26 +81,47 @@ partial void ProcessListApiKeysResponseContent( securityRequirements: s_ListApiKeysSecurityRequirements, operationName: "ListApiKeysAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/api-keys", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("offset", offset?.ToString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/api-keys", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("offset", offset?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -107,151 +131,310 @@ partial void ProcessListApiKeysResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListApiKeysRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - limit: limit, - offset: offset); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListApiKeysRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + limit: limit, + offset: offset); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListApiKeysResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListApiKeys", + methodName: "ListApiKeysAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListApiKeys", + methodName: "ListApiKeysAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListApiKeys", + methodName: "ListApiKeysAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListApiKeysResponseContent( + response: __response); + ProcessListApiKeysResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKeyListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListApiKeys", + methodName: "ListApiKeysAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListApiKeys", + methodName: "ListApiKeysAsync", + pathTemplate: "\"/v1/api-keys\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKeyListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListApiKeysResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKeyListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKeyListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RerollApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RerollApiKey.g.cs index d4e1f53..8ef83c8 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RerollApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RerollApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,10 +53,12 @@ partial void ProcessRerollApiKeyResponseContent( /// /// The ID of the API key to reroll /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RerollApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -70,22 +73,43 @@ partial void ProcessRerollApiKeyResponseContent( securityRequirements: s_RerollApiKeySecurityRequirements, operationName: "RerollApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/api-keys/{apiKeyId}/reroll", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/api-keys/{apiKeyId}/reroll", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,150 +119,309 @@ partial void ProcessRerollApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRerollApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - apiKeyId: apiKeyId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRerollApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + apiKeyId: apiKeyId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRerollApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RerollApiKey", + methodName: "RerollApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/reroll\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RerollApiKey", + methodName: "RerollApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/reroll\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RerollApiKey", + methodName: "RerollApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/reroll\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRerollApiKeyResponseContent( + response: __response); + ProcessRerollApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKeyCreated.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RerollApiKey", + methodName: "RerollApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/reroll\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RerollApiKey", + methodName: "RerollApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/reroll\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKeyCreated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRerollApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKeyCreated.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKeyCreated.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RetrieveApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RetrieveApiKey.g.cs index e32f320..d28857b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RetrieveApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RetrieveApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveApiKeyResponseContent( /// /// The ID of the API key to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveApiKeyResponseContent( securityRequirements: s_RetrieveApiKeySecurityRequirements, operationName: "RetrieveApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/api-keys/{apiKeyId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/api-keys/{apiKeyId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRetrieveApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - apiKeyId: apiKeyId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + apiKeyId: apiKeyId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveApiKey", + methodName: "RetrieveApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveApiKey", + methodName: "RetrieveApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveApiKey", + methodName: "RetrieveApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveApiKeyResponseContent( + response: __response); + ProcessRetrieveApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveApiKey", + methodName: "RetrieveApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveApiKey", + methodName: "RetrieveApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RevokeApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RevokeApiKey.g.cs index 673a8cf..b358987 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RevokeApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.RevokeApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRevokeApiKeyResponseContent( /// /// The ID of the API key to revoke /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RevokeApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRevokeApiKeyResponseContent( securityRequirements: s_RevokeApiKeySecurityRequirements, operationName: "RevokeApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/api-keys/{apiKeyId}/revoke", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/api-keys/{apiKeyId}/revoke", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRevokeApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRevokeApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - apiKeyId: apiKeyId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRevokeApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + apiKeyId: apiKeyId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRevokeApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeApiKey", + methodName: "RevokeApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/revoke\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeApiKey", + methodName: "RevokeApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/revoke\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeApiKey", + methodName: "RevokeApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/revoke\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRevokeApiKeyResponseContent( + response: __response); + ProcessRevokeApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeApiKey", + methodName: "RevokeApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/revoke\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RevokeApiKey", + methodName: "RevokeApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}/revoke\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRevokeApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.UpdateApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.UpdateApiKey.g.cs index 8336599..75228b0 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.UpdateApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.UpdateApiKey.g.cs @@ -14,6 +14,7 @@ public partial class ApiKeysClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessUpdateApiKeyResponseContent( /// The ID of the API key to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateApiKeyAsync( global::System.Guid apiKeyId, global::Mixedbread.ApiKeyUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessUpdateApiKeyResponseContent( securityRequirements: s_UpdateApiKeySecurityRequirements, operationName: "UpdateApiKeyAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/api-keys/{apiKeyId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/api-keys/{apiKeyId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessUpdateApiKeyResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateApiKeyRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - apiKeyId: apiKeyId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateApiKeyRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + apiKeyId: apiKeyId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateApiKeyResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateApiKey", + methodName: "UpdateApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateApiKey", + methodName: "UpdateApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateApiKey", + methodName: "UpdateApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateApiKeyResponseContent( + response: __response); + ProcessUpdateApiKeyResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateApiKey", + methodName: "UpdateApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateApiKey", + methodName: "UpdateApiKeyAsync", + pathTemplate: "$\"/v1/api-keys/{apiKeyId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateApiKeyResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ApiKey.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ApiKey.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update API key
@@ -273,12 +456,14 @@ partial void ProcessUpdateApiKeyResponseContent( /// /// Optional expiration datetime /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateApiKeyAsync( global::System.Guid apiKeyId, string? name = default, global::System.DateTime? expiresAt = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.ApiKeyUpdateParams @@ -290,6 +475,7 @@ partial void ProcessUpdateApiKeyResponseContent( return await UpdateApiKeyAsync( apiKeyId: apiKeyId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.g.cs index 4b66448..7afe661 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ApiKeysClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ApiKeysClient : global::Mixedbread.IApiKeysClient, g #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ApiKeysClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ApiKeysClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ApiKeysClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetBillingSummary.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetBillingSummary.g.cs index 44f8235..ed47c6c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetBillingSummary.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetBillingSummary.g.cs @@ -14,6 +14,7 @@ public partial class BillingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,9 +42,11 @@ partial void ProcessGetBillingSummaryResponseContent( /// /// Get billing summary /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetBillingSummaryAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -57,22 +60,43 @@ partial void ProcessGetBillingSummaryResponseContent( securityRequirements: s_GetBillingSummarySecurityRequirements, operationName: "GetBillingSummaryAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/billing/summary", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/billing/summary", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -82,111 +106,270 @@ partial void ProcessGetBillingSummaryResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetBillingSummaryRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetBillingSummaryRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetBillingSummaryResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBillingSummary", + methodName: "GetBillingSummaryAsync", + pathTemplate: "\"/v1/billing/summary\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBillingSummary", + methodName: "GetBillingSummaryAsync", + pathTemplate: "\"/v1/billing/summary\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetBillingSummaryResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBillingSummary", + methodName: "GetBillingSummaryAsync", + pathTemplate: "\"/v1/billing/summary\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Mixedbread.BillingPeriodSummary.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Mixedbread.BillingPeriodSummary.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetBillingSummaryResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBillingSummary", + methodName: "GetBillingSummaryAsync", + pathTemplate: "\"/v1/billing/summary\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetBillingSummary", + methodName: "GetBillingSummaryAsync", + pathTemplate: "\"/v1/billing/summary\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetBillingSummaryResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.BillingPeriodSummary.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.BillingPeriodSummary.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetParsingCostHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetParsingCostHistogram.g.cs index cadfb08..df769e2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetParsingCostHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetParsingCostHistogram.g.cs @@ -14,6 +14,7 @@ public partial class BillingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,9 +42,11 @@ partial void ProcessGetParsingCostHistogramResponseContent( /// /// Get parsing cost histogram /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetParsingCostHistogramAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -57,22 +60,43 @@ partial void ProcessGetParsingCostHistogramResponseContent( securityRequirements: s_GetParsingCostHistogramSecurityRequirements, operationName: "GetParsingCostHistogramAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/billing/parsing/costs/histogram", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/billing/parsing/costs/histogram", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -82,111 +106,270 @@ partial void ProcessGetParsingCostHistogramResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetParsingCostHistogramRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetParsingCostHistogramRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetParsingCostHistogramResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetParsingCostHistogram", + methodName: "GetParsingCostHistogramAsync", + pathTemplate: "\"/v1/billing/parsing/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetParsingCostHistogram", + methodName: "GetParsingCostHistogramAsync", + pathTemplate: "\"/v1/billing/parsing/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetParsingCostHistogramResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetParsingCostHistogram", + methodName: "GetParsingCostHistogramAsync", + pathTemplate: "\"/v1/billing/parsing/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Mixedbread.CostHistogramResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Mixedbread.CostHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetParsingCostHistogramResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetParsingCostHistogram", + methodName: "GetParsingCostHistogramAsync", + pathTemplate: "\"/v1/billing/parsing/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetParsingCostHistogram", + methodName: "GetParsingCostHistogramAsync", + pathTemplate: "\"/v1/billing/parsing/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetParsingCostHistogramResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.CostHistogramResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.CostHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetStoreCostHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetStoreCostHistogram.g.cs index cd8c253..a84ffe1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetStoreCostHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.GetStoreCostHistogram.g.cs @@ -14,6 +14,7 @@ public partial class BillingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -46,10 +47,12 @@ partial void ProcessGetStoreCostHistogramResponseContent( /// /// The ID of the store /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetStoreCostHistogramAsync( global::System.Guid storeId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -64,22 +67,43 @@ partial void ProcessGetStoreCostHistogramResponseContent( securityRequirements: s_GetStoreCostHistogramSecurityRequirements, operationName: "GetStoreCostHistogramAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/billing/stores/{storeId}/costs/histogram", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/billing/stores/{storeId}/costs/histogram", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -89,150 +113,309 @@ partial void ProcessGetStoreCostHistogramResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetStoreCostHistogramRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeId: storeId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetStoreCostHistogramRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeId: storeId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetStoreCostHistogramResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreCostHistogram", + methodName: "GetStoreCostHistogramAsync", + pathTemplate: "$\"/v1/billing/stores/{storeId}/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreCostHistogram", + methodName: "GetStoreCostHistogramAsync", + pathTemplate: "$\"/v1/billing/stores/{storeId}/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreCostHistogram", + methodName: "GetStoreCostHistogramAsync", + pathTemplate: "$\"/v1/billing/stores/{storeId}/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetStoreCostHistogramResponseContent( + response: __response); + ProcessGetStoreCostHistogramResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.CostHistogramResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreCostHistogram", + methodName: "GetStoreCostHistogramAsync", + pathTemplate: "$\"/v1/billing/stores/{storeId}/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreCostHistogram", + methodName: "GetStoreCostHistogramAsync", + pathTemplate: "$\"/v1/billing/stores/{storeId}/costs/histogram\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.CostHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetStoreCostHistogramResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.CostHistogramResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.CostHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.ListStoreCostInfo.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.ListStoreCostInfo.g.cs index ee11d48..d836d03 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.ListStoreCostInfo.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.ListStoreCostInfo.g.cs @@ -14,6 +14,7 @@ public partial class BillingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -41,9 +42,11 @@ partial void ProcessListStoreCostInfoResponseContent( /// /// List store cost information /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListStoreCostInfoAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -57,22 +60,43 @@ partial void ProcessListStoreCostInfoResponseContent( securityRequirements: s_ListStoreCostInfoSecurityRequirements, operationName: "ListStoreCostInfoAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/billing/stores", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/billing/stores", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -82,111 +106,270 @@ partial void ProcessListStoreCostInfoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListStoreCostInfoRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListStoreCostInfoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListStoreCostInfoResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreCostInfo", + methodName: "ListStoreCostInfoAsync", + pathTemplate: "\"/v1/billing/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreCostInfo", + methodName: "ListStoreCostInfoAsync", + pathTemplate: "\"/v1/billing/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessListStoreCostInfoResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreCostInfo", + methodName: "ListStoreCostInfoAsync", + pathTemplate: "\"/v1/billing/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Mixedbread.StoreCostListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Mixedbread.StoreCostListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListStoreCostInfoResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreCostInfo", + methodName: "ListStoreCostInfoAsync", + pathTemplate: "\"/v1/billing/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreCostInfo", + methodName: "ListStoreCostInfoAsync", + pathTemplate: "\"/v1/billing/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListStoreCostInfoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreCostListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreCostListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.g.cs index 53f15b7..a9e4bde 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.BillingClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class BillingClient : global::Mixedbread.IBillingClient, g #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public BillingClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the BillingClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public BillingClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.CreateChatCompletion.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.CreateChatCompletion.g.cs index bdd2955..ebe667e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.CreateChatCompletion.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.CreateChatCompletion.g.cs @@ -14,6 +14,7 @@ public partial class CompletionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -52,9 +53,11 @@ partial void ProcessCreateChatCompletionResponseContent( /// Raises:
/// HTTPException: If there is an error creating the completion (500) ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateChatCompletionAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +71,43 @@ partial void ProcessCreateChatCompletionResponseContent( securityRequirements: s_CreateChatCompletionSecurityRequirements, operationName: "CreateChatCompletionAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/chat/completions", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/chat/completions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,107 +117,266 @@ partial void ProcessCreateChatCompletionResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateChatCompletionRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateChatCompletionRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateChatCompletionResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateChatCompletion", + methodName: "CreateChatCompletionAsync", + pathTemplate: "\"/v1/chat/completions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateChatCompletion", + methodName: "CreateChatCompletionAsync", + pathTemplate: "\"/v1/chat/completions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateChatCompletionResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateChatCompletion", + methodName: "CreateChatCompletionAsync", + pathTemplate: "\"/v1/chat/completions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return __content; + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return __content; + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreateChatCompletionResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateChatCompletion", + methodName: "CreateChatCompletionAsync", + pathTemplate: "\"/v1/chat/completions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateChatCompletion", + methodName: "CreateChatCompletionAsync", + pathTemplate: "\"/v1/chat/completions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateChatCompletionResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.g.cs index 1d33404..be9cb1d 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.CompletionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class CompletionsClient : global::Mixedbread.ICompletionsC #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public CompletionsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the CompletionsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public CompletionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.AuthorizeDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.AuthorizeDataSource.g.cs index f6814ce..bbde35d 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.AuthorizeDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.AuthorizeDataSource.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,10 +58,12 @@ partial void ProcessAuthorizeDataSourceResponseContent( /// /// The ID of the data source to authorize /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task AuthorizeDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -75,22 +78,43 @@ partial void ProcessAuthorizeDataSourceResponseContent( securityRequirements: s_AuthorizeDataSourceSecurityRequirements, operationName: "AuthorizeDataSourceAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/oauth2/authorize", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/oauth2/authorize", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -100,146 +124,305 @@ partial void ProcessAuthorizeDataSourceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAuthorizeDataSourceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAuthorizeDataSourceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAuthorizeDataSourceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AuthorizeDataSource", + methodName: "AuthorizeDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/oauth2/authorize\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AuthorizeDataSource", + methodName: "AuthorizeDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/oauth2/authorize\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AuthorizeDataSource", + methodName: "AuthorizeDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/oauth2/authorize\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessAuthorizeDataSourceResponseContent( + response: __response); + ProcessAuthorizeDataSourceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AuthorizeDataSource", + methodName: "AuthorizeDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/oauth2/authorize\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AuthorizeDataSource", + methodName: "AuthorizeDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/oauth2/authorize\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessAuthorizeDataSourceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateConnector.g.cs index a3c19ff..bd6869a 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateConnector.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessCreateConnectorResponseContent( /// The ID of the data source to create a connector for /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateConnectorAsync( global::System.Guid dataSourceId, global::Mixedbread.DataSourceConnectorCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessCreateConnectorResponseContent( securityRequirements: s_CreateConnectorSecurityRequirements, operationName: "CreateConnectorAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/connectors", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/connectors", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessCreateConnectorResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateConnectorRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateConnectorRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateConnectorResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateConnector", + methodName: "CreateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateConnector", + methodName: "CreateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateConnector", + methodName: "CreateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateConnectorResponseContent( + response: __response); + ProcessCreateConnectorResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateConnector", + methodName: "CreateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateConnector", + methodName: "CreateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateConnectorResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create a new connector
@@ -287,6 +470,7 @@ partial void ProcessCreateConnectorResponseContent( /// - str: Duration string (e.g., '30m', '1h', '2d') or ISO 8601 format (e.g., 'PT30M', 'P1D')
/// Valid range: 15 seconds to 30 days /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateConnectorAsync( @@ -296,6 +480,7 @@ partial void ProcessCreateConnectorResponseContent( bool? triggerSync = default, object? metadata = default, global::Mixedbread.AnyOf? pollingInterval = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.DataSourceConnectorCreateParams @@ -310,6 +495,7 @@ partial void ProcessCreateConnectorResponseContent( return await CreateConnectorAsync( dataSourceId: dataSourceId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateDataSource.g.cs index e6c1ea7..c72e024 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.CreateDataSource.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateDataSourceResponseContent( /// The created data source. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateDataSourceAsync( global::Mixedbread.AnyOf request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -68,22 +71,43 @@ partial void ProcessCreateDataSourceResponseContent( securityRequirements: s_CreateDataSourceSecurityRequirements, operationName: "CreateDataSourceAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/data_sources/", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/data_sources/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -93,156 +117,315 @@ partial void ProcessCreateDataSourceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateDataSourceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateDataSourceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateDataSourceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateDataSource", + methodName: "CreateDataSourceAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateDataSource", + methodName: "CreateDataSourceAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateDataSource", + methodName: "CreateDataSourceAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateDataSourceResponseContent( + response: __response); + ProcessCreateDataSourceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateDataSource", + methodName: "CreateDataSourceAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateDataSource", + methodName: "CreateDataSourceAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateDataSourceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create a new data source
@@ -252,9 +435,11 @@ partial void ProcessCreateDataSourceResponseContent( /// Returns:
/// The created data source. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateDataSourceAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.AnyOf @@ -263,6 +448,7 @@ partial void ProcessCreateDataSourceResponseContent( return await CreateDataSourceAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteConnector.g.cs index 76a351f..b7b4587 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteConnector.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessDeleteConnectorResponseContent( /// /// The ID of the connector to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteConnectorAsync( global::System.Guid dataSourceId, global::System.Guid connectorId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessDeleteConnectorResponseContent( securityRequirements: s_DeleteConnectorSecurityRequirements, operationName: "DeleteConnectorAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,151 +126,310 @@ partial void ProcessDeleteConnectorResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteConnectorRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - connectorId: connectorId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteConnectorRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + connectorId: connectorId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteConnectorResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteConnector", + methodName: "DeleteConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteConnector", + methodName: "DeleteConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteConnector", + methodName: "DeleteConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteConnectorResponseContent( + response: __response); + ProcessDeleteConnectorResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceConnectorDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteConnector", + methodName: "DeleteConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteConnector", + methodName: "DeleteConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceConnectorDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteConnectorResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceConnectorDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceConnectorDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteDataSource.g.cs index a960e71..2982f0b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.DeleteDataSource.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,10 +50,12 @@ partial void ProcessDeleteDataSourceResponseContent( /// /// The ID of the data source to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -67,22 +70,43 @@ partial void ProcessDeleteDataSourceResponseContent( securityRequirements: s_DeleteDataSourceSecurityRequirements, operationName: "DeleteDataSourceAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -92,150 +116,309 @@ partial void ProcessDeleteDataSourceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteDataSourceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteDataSourceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteDataSourceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteDataSource", + methodName: "DeleteDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteDataSource", + methodName: "DeleteDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteDataSource", + methodName: "DeleteDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteDataSourceResponseContent( + response: __response); + ProcessDeleteDataSourceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteDataSource", + methodName: "DeleteDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteDataSource", + methodName: "DeleteDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteDataSourceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetConnector.g.cs index 9befadd..4b07100 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetConnector.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessGetConnectorResponseContent( /// /// The ID of the connector to get /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetConnectorAsync( global::System.Guid dataSourceId, global::System.Guid connectorId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessGetConnectorResponseContent( securityRequirements: s_GetConnectorSecurityRequirements, operationName: "GetConnectorAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,151 +126,310 @@ partial void ProcessGetConnectorResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetConnectorRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - connectorId: connectorId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetConnectorRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + connectorId: connectorId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetConnectorResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetConnector", + methodName: "GetConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetConnector", + methodName: "GetConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetConnector", + methodName: "GetConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetConnectorResponseContent( + response: __response); + ProcessGetConnectorResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetConnector", + methodName: "GetConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetConnector", + methodName: "GetConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetConnectorResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetDataSource.g.cs index a76cc92..b8e0333 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.GetDataSource.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessGetDataSourceResponseContent( /// /// The ID of the data source to fetch /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessGetDataSourceResponseContent( securityRequirements: s_GetDataSourceSecurityRequirements, operationName: "GetDataSourceAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessGetDataSourceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetDataSourceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetDataSourceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetDataSourceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDataSource", + methodName: "GetDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDataSource", + methodName: "GetDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDataSource", + methodName: "GetDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetDataSourceResponseContent( + response: __response); + ProcessGetDataSourceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDataSource", + methodName: "GetDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetDataSource", + methodName: "GetDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetDataSourceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListConnectors.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListConnectors.g.cs index 8eca39f..7c398ff 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListConnectors.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListConnectors.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -74,6 +75,7 @@ partial void ProcessListConnectorsResponseContent( /// Whether to include total count in response (expensive operation)
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListConnectorsAsync( @@ -82,6 +84,7 @@ partial void ProcessListConnectorsResponseContent( string? after = default, string? before = default, bool? includeTotal = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -100,28 +103,49 @@ partial void ProcessListConnectorsResponseContent( securityRequirements: s_ListConnectorsSecurityRequirements, operationName: "ListConnectorsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/connectors", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/connectors", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -131,154 +155,313 @@ partial void ProcessListConnectorsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListConnectorsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListConnectorsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListConnectorsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListConnectors", + methodName: "ListConnectorsAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListConnectors", + methodName: "ListConnectorsAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListConnectors", + methodName: "ListConnectorsAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListConnectorsResponseContent( + response: __response); + ProcessListConnectorsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ConnectorListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListConnectors", + methodName: "ListConnectorsAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListConnectors", + methodName: "ListConnectorsAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ConnectorListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListConnectorsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ConnectorListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ConnectorListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListDataSources.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListDataSources.g.cs index a0d435a..27e3449 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListDataSources.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.ListDataSources.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -66,6 +67,7 @@ partial void ProcessListDataSourcesResponseContent( /// Whether to include total count in response (expensive operation)
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListDataSourcesAsync( @@ -73,6 +75,7 @@ partial void ProcessListDataSourcesResponseContent( string? after = default, string? before = default, bool? includeTotal = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -90,28 +93,49 @@ partial void ProcessListDataSourcesResponseContent( securityRequirements: s_ListDataSourcesSecurityRequirements, operationName: "ListDataSourcesAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/data_sources/", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/data_sources/", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -121,153 +145,312 @@ partial void ProcessListDataSourcesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListDataSourcesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListDataSourcesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListDataSourcesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListDataSources", + methodName: "ListDataSourcesAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListDataSources", + methodName: "ListDataSourcesAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListDataSources", + methodName: "ListDataSourcesAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListDataSourcesResponseContent( + response: __response); + ProcessListDataSourcesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListDataSources", + methodName: "ListDataSourcesAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListDataSources", + methodName: "ListDataSourcesAsync", + pathTemplate: "\"/v1/data_sources/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListDataSourcesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.Oauth2Callback.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.Oauth2Callback.g.cs index 09919a3..bc832fe 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.Oauth2Callback.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.Oauth2Callback.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -70,6 +71,7 @@ partial void ProcessOauth2CallbackResponse( /// /// Human-readable error description /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task Oauth2CallbackAsync( @@ -77,6 +79,7 @@ partial void ProcessOauth2CallbackResponse( string code, string? error = default, string? errorDescription = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -94,28 +97,49 @@ partial void ProcessOauth2CallbackResponse( securityRequirements: s_Oauth2CallbackSecurityRequirements, operationName: "Oauth2CallbackAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/data_sources/oauth2/callback", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddRequiredParameter("state", state) - .AddRequiredParameter("code", code) - .AddOptionalParameter("error", error) - .AddOptionalParameter("error_description", errorDescription) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/data_sources/oauth2/callback", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddRequiredParameter("state", state) + .AddRequiredParameter("code", code) + .AddOptionalParameter("error", error) + .AddOptionalParameter("error_description", errorDescription) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -125,240 +149,399 @@ partial void ProcessOauth2CallbackResponse( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareOauth2CallbackRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - state: state, - code: code, - error: error, - errorDescription: errorDescription); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareOauth2CallbackRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + state: state, + code: code, + error: error, + errorDescription: errorDescription); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessOauth2CallbackResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Successful authorization, redirect to data source - if ((int)__response.StatusCode == 307) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_307 = null; - global::System.Exception? __exception_307 = null; - string? __value_307 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Oauth2Callback", + methodName: "Oauth2CallbackAsync", + pathTemplate: "\"/v1/data_sources/oauth2/callback\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_307 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_307 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Oauth2Callback", + methodName: "Oauth2CallbackAsync", + pathTemplate: "\"/v1/data_sources/oauth2/callback\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } - } - catch (global::System.Exception __ex) - { - __exception_307 = __ex; - } - throw new global::Mixedbread.ApiException( - message: __content_307 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_307, - statusCode: __response.StatusCode) - { - ResponseBody = __content_307, - ResponseObject = __value_307, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 400) - { - string? __content_400 = null; - global::System.Exception? __exception_400 = null; - try - { - if (ReadResponseAsString) + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_400 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Oauth2Callback", + methodName: "Oauth2CallbackAsync", + pathTemplate: "\"/v1/data_sources/oauth2/callback\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_400 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_400, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_400, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // - if ((int)__response.StatusCode == 404) - { - string? __content_404 = null; - global::System.Exception? __exception_404 = null; - try + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessOauth2CallbackResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - if (ReadResponseAsString) - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } - else - { - __content_404 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Oauth2Callback", + methodName: "Oauth2CallbackAsync", + pathTemplate: "\"/v1/data_sources/oauth2/callback\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - __exception_404 = __ex; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Oauth2Callback", + methodName: "Oauth2CallbackAsync", + pathTemplate: "\"/v1/data_sources/oauth2/callback\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } + // Successful authorization, redirect to data source + if ((int)__response.StatusCode == 307) + { + string? __content_307 = null; + global::System.Exception? __exception_307 = null; + string? __value_307 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_307 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + } + else + { + __content_307 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - throw new global::Mixedbread.ApiException( - message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_404, - statusCode: __response.StatusCode) - { - ResponseBody = __content_404, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - // Validation Error - if ((int)__response.StatusCode == 422) - { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try - { - if (ReadResponseAsString) - { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - else - { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + __value_307 = (string?)global::System.Text.Json.JsonSerializer.Deserialize(__content_307, typeof(string), JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_307 = __ex; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); - } - } - catch (global::System.Exception __ex) - { - __exception_422 = __ex; - } + throw new global::Mixedbread.ApiException( + message: __content_307 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_307, + statusCode: __response.StatusCode) + { + ResponseBody = __content_307, + ResponseObject = __value_307, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 400) + { + string? __content_400 = null; + global::System.Exception? __exception_400 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_400 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_400 = __ex; + } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) - { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + throw new global::Mixedbread.ApiException( + message: __content_400 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_400, + statusCode: __response.StatusCode) + { + ResponseBody = __content_400, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // + if ((int)__response.StatusCode == 404) + { + string? __content_404 = null; + global::System.Exception? __exception_404 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + else + { + __content_404 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + } + } + catch (global::System.Exception __ex) + { + __exception_404 = __ex; + } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + throw new global::Mixedbread.ApiException( + message: __content_404 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_404, + statusCode: __response.StatusCode) + { + ResponseBody = __content_404, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } - try - { - __response.EnsureSuccessStatusCode(); + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - } - catch (global::System.Exception __ex) - { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } - else + finally { - try - { - __response.EnsureSuccessStatusCode(); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } - - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } + __httpRequest?.Dispose(); } } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateConnector.g.cs index 28df02d..00b7ac4 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateConnector.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,6 +62,7 @@ partial void ProcessUpdateConnectorResponseContent( /// The ID of the connector to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateConnectorAsync( @@ -68,6 +70,7 @@ partial void ProcessUpdateConnectorResponseContent( global::System.Guid connectorId, global::Mixedbread.DataSourceConnectorUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -86,22 +89,43 @@ partial void ProcessUpdateConnectorResponseContent( securityRequirements: s_UpdateConnectorSecurityRequirements, operationName: "UpdateConnectorAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}/connectors/{connectorId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,158 +135,317 @@ partial void ProcessUpdateConnectorResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateConnectorRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - connectorId: connectorId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateConnectorRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + connectorId: connectorId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateConnectorResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateConnector", + methodName: "UpdateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateConnector", + methodName: "UpdateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateConnector", + methodName: "UpdateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateConnectorResponseContent( + response: __response); + ProcessUpdateConnectorResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateConnector", + methodName: "UpdateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateConnector", + methodName: "UpdateConnectorAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}/connectors/{connectorId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateConnectorResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSourceConnector.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSourceConnector.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update a connector
@@ -295,6 +478,7 @@ partial void ProcessUpdateConnectorResponseContent( /// - str: Duration string (e.g., '30m', '1h', '2d') or ISO 8601 format (e.g., 'PT30M', 'P1D')
/// Valid range: 15 seconds to 30 days /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateConnectorAsync( @@ -304,6 +488,7 @@ partial void ProcessUpdateConnectorResponseContent( object? metadata = default, bool? triggerSync = default, global::Mixedbread.AnyOf? pollingInterval = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.DataSourceConnectorUpdateParams @@ -318,6 +503,7 @@ partial void ProcessUpdateConnectorResponseContent( dataSourceId: dataSourceId, connectorId: connectorId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateDataSource.g.cs index 69f6ad1..d7afa78 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.UpdateDataSource.g.cs @@ -14,6 +14,7 @@ public partial class DataSourcesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessUpdateDataSourceResponseContent( /// The ID of the data source to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateDataSourceAsync( global::System.Guid dataSourceId, global::Mixedbread.AnyOf request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -76,22 +79,43 @@ partial void ProcessUpdateDataSourceResponseContent( securityRequirements: s_UpdateDataSourceSecurityRequirements, operationName: "UpdateDataSourceAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/data_sources/{dataSourceId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/data_sources/{dataSourceId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -101,157 +125,316 @@ partial void ProcessUpdateDataSourceResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateDataSourceRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - dataSourceId: dataSourceId, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateDataSourceRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + dataSourceId: dataSourceId, + request: request); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateDataSourceResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDataSource", + methodName: "UpdateDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDataSource", + methodName: "UpdateDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDataSource", + methodName: "UpdateDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateDataSourceResponseContent( + response: __response); + ProcessUpdateDataSourceResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDataSource", + methodName: "UpdateDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateDataSource", + methodName: "UpdateDataSourceAsync", + pathTemplate: "$\"/v1/data_sources/{dataSourceId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateDataSourceResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.DataSource.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.DataSource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update a data source
@@ -265,10 +448,12 @@ partial void ProcessUpdateDataSourceResponseContent( /// /// The ID of the data source to update /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.AnyOf @@ -278,6 +463,7 @@ partial void ProcessUpdateDataSourceResponseContent( return await UpdateDataSourceAsync( dataSourceId: dataSourceId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.g.cs index 36bb125..f5fe9b8 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.DataSourcesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class DataSourcesClient : global::Mixedbread.IDataSourcesC #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public DataSourcesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the DataSourcesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public DataSourcesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateExtractionJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateExtractionJob.g.cs index 7255326..347e7ce 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateExtractionJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateExtractionJob.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateExtractionJobResponseContent( /// The created extraction job. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateExtractionJobAsync( global::Mixedbread.ExtractJobCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateExtractionJobResponseContent( securityRequirements: s_CreateExtractionJobSecurityRequirements, operationName: "CreateExtractionJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/extractions/jobs", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/extractions/jobs", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateExtractionJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateExtractionJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateExtractionJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateExtractionJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateExtractionJob", + methodName: "CreateExtractionJobAsync", + pathTemplate: "\"/v1/extractions/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateExtractionJob", + methodName: "CreateExtractionJobAsync", + pathTemplate: "\"/v1/extractions/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateExtractionJob", + methodName: "CreateExtractionJobAsync", + pathTemplate: "\"/v1/extractions/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateExtractionJobResponseContent( + response: __response); + ProcessCreateExtractionJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ExtractionJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateExtractionJob", + methodName: "CreateExtractionJobAsync", + pathTemplate: "\"/v1/extractions/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateExtractionJob", + methodName: "CreateExtractionJobAsync", + pathTemplate: "\"/v1/extractions/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ExtractionJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateExtractionJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ExtractionJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ExtractionJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Start an extraction job
@@ -260,11 +443,13 @@ partial void ProcessCreateExtractionJobResponseContent( /// /// The JSON schema to use for extraction /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateExtractionJobAsync( string fileId, object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.ExtractJobCreateParams @@ -275,6 +460,7 @@ partial void ProcessCreateExtractionJobResponseContent( return await CreateExtractionJobAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateSchema.g.cs index e877c12..b8c559e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.CreateSchema.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateSchemaResponseContent( /// The created schema. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateSchemaAsync( global::Mixedbread.JsonSchemaCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateSchemaResponseContent( securityRequirements: s_CreateSchemaSecurityRequirements, operationName: "CreateSchemaAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/extractions/schema", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/extractions/schema", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateSchemaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateSchemaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSchemaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateSchemaResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSchema", + methodName: "CreateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSchema", + methodName: "CreateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSchema", + methodName: "CreateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateSchemaResponseContent( + response: __response); + ProcessCreateSchemaResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.CreatedJsonSchema.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSchema", + methodName: "CreateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSchema", + methodName: "CreateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.CreatedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateSchemaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.CreatedJsonSchema.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.CreatedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create a schema
@@ -257,10 +440,12 @@ partial void ProcessCreateSchemaResponseContent( /// /// Description of the data to extract /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateSchemaAsync( string description, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.JsonSchemaCreateParams @@ -270,6 +455,7 @@ partial void ProcessCreateSchemaResponseContent( return await CreateSchemaAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.EnhanceSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.EnhanceSchema.g.cs index 884de3e..9a0a0af 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.EnhanceSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.EnhanceSchema.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessEnhanceSchemaResponseContent( /// The enhanced schema. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task EnhanceSchemaAsync( global::Mixedbread.JsonSchemaEnhanceParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessEnhanceSchemaResponseContent( securityRequirements: s_EnhanceSchemaSecurityRequirements, operationName: "EnhanceSchemaAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/extractions/schema/enhance", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/extractions/schema/enhance", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessEnhanceSchemaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareEnhanceSchemaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareEnhanceSchemaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessEnhanceSchemaResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhanceSchema", + methodName: "EnhanceSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/enhance\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhanceSchema", + methodName: "EnhanceSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/enhance\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhanceSchema", + methodName: "EnhanceSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/enhance\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessEnhanceSchemaResponseContent( + response: __response); + ProcessEnhanceSchemaResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.EnhancedJsonSchema.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhanceSchema", + methodName: "EnhanceSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/enhance\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "EnhanceSchema", + methodName: "EnhanceSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/enhance\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.EnhancedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessEnhanceSchemaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.EnhancedJsonSchema.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.EnhancedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Enhance a schema
@@ -257,10 +440,12 @@ partial void ProcessEnhanceSchemaResponseContent( /// /// The JSON schema to enhance /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task EnhanceSchemaAsync( object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.JsonSchemaEnhanceParams @@ -270,6 +455,7 @@ partial void ProcessEnhanceSchemaResponseContent( return await EnhanceSchemaAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ExtractContent.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ExtractContent.g.cs index ad1924f..4501d4e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ExtractContent.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ExtractContent.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessExtractContentResponseContent( /// The extracted content. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ExtractContentAsync( global::Mixedbread.ExtractContentCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessExtractContentResponseContent( securityRequirements: s_ExtractContentSecurityRequirements, operationName: "ExtractContentAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/extractions/content", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/extractions/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessExtractContentResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareExtractContentRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareExtractContentRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessExtractContentResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExtractContent", + methodName: "ExtractContentAsync", + pathTemplate: "\"/v1/extractions/content\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExtractContent", + methodName: "ExtractContentAsync", + pathTemplate: "\"/v1/extractions/content\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExtractContent", + methodName: "ExtractContentAsync", + pathTemplate: "\"/v1/extractions/content\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessExtractContentResponseContent( + response: __response); + ProcessExtractContentResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ExtractionResult.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExtractContent", + methodName: "ExtractContentAsync", + pathTemplate: "\"/v1/extractions/content\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ExtractContent", + methodName: "ExtractContentAsync", + pathTemplate: "\"/v1/extractions/content\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ExtractionResult.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessExtractContentResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ExtractionResult.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ExtractionResult.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Extract content from a string
@@ -263,12 +446,14 @@ partial void ProcessExtractContentResponseContent( /// /// Additional instructions for the extraction /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ExtractContentAsync( global::Mixedbread.AnyOf, global::System.Collections.Generic.IList>> content, object jsonSchema, string? instructions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.ExtractContentCreateParams @@ -280,6 +465,7 @@ partial void ProcessExtractContentResponseContent( return await ExtractContentAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.RetrieveExtractionJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.RetrieveExtractionJob.g.cs index ac596df..aa19ba1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.RetrieveExtractionJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.RetrieveExtractionJob.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveExtractionJobResponseContent( /// /// The ID of the extraction job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveExtractionJobAsync( string jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveExtractionJobResponseContent( securityRequirements: s_RetrieveExtractionJobSecurityRequirements, operationName: "RetrieveExtractionJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/extractions/jobs/{jobId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/extractions/jobs/{jobId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRetrieveExtractionJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveExtractionJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveExtractionJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveExtractionJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveExtractionJob", + methodName: "RetrieveExtractionJobAsync", + pathTemplate: "$\"/v1/extractions/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveExtractionJob", + methodName: "RetrieveExtractionJobAsync", + pathTemplate: "$\"/v1/extractions/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveExtractionJob", + methodName: "RetrieveExtractionJobAsync", + pathTemplate: "$\"/v1/extractions/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveExtractionJobResponseContent( + response: __response); + ProcessRetrieveExtractionJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ExtractionJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveExtractionJob", + methodName: "RetrieveExtractionJobAsync", + pathTemplate: "$\"/v1/extractions/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveExtractionJob", + methodName: "RetrieveExtractionJobAsync", + pathTemplate: "$\"/v1/extractions/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ExtractionJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveExtractionJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ExtractionJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ExtractionJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ValidateSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ValidateSchema.g.cs index 5210759..3e3c293 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ValidateSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.ValidateSchema.g.cs @@ -14,6 +14,7 @@ public partial class ExtractionsClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessValidateSchemaResponseContent( /// The validation result. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ValidateSchemaAsync( global::Mixedbread.JsonSchemaValidateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessValidateSchemaResponseContent( securityRequirements: s_ValidateSchemaSecurityRequirements, operationName: "ValidateSchemaAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/extractions/schema/validate", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/extractions/schema/validate", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessValidateSchemaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareValidateSchemaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareValidateSchemaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessValidateSchemaResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateSchema", + methodName: "ValidateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/validate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateSchema", + methodName: "ValidateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/validate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateSchema", + methodName: "ValidateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/validate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessValidateSchemaResponseContent( + response: __response); + ProcessValidateSchemaResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ValidatedJsonSchema.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateSchema", + methodName: "ValidateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/validate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ValidateSchema", + methodName: "ValidateSchemaAsync", + pathTemplate: "\"/v1/extractions/schema/validate\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ValidatedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessValidateSchemaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ValidatedJsonSchema.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ValidatedJsonSchema.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Validate a schema
@@ -257,10 +440,12 @@ partial void ProcessValidateSchemaResponseContent( /// /// The JSON schema to validate /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ValidateSchemaAsync( object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.JsonSchemaValidateParams @@ -270,6 +455,7 @@ partial void ProcessValidateSchemaResponseContent( return await ValidateSchemaAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.g.cs index 52f755f..c615893 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ExtractionsClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ExtractionsClient : global::Mixedbread.IExtractionsC #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ExtractionsClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ExtractionsClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ExtractionsClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.AbortMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.AbortMultipartUpload.g.cs index 765403a..c89fad8 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.AbortMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.AbortMultipartUpload.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,12 @@ partial void ProcessAbortMultipartUploadResponseContent( /// /// The ID of the multipart upload to abort /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task AbortMultipartUploadAsync( global::System.Guid uploadId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +68,43 @@ partial void ProcessAbortMultipartUploadResponseContent( securityRequirements: s_AbortMultipartUploadSecurityRequirements, operationName: "AbortMultipartUploadAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/uploads/{uploadId}/abort", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/uploads/{uploadId}/abort", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +114,309 @@ partial void ProcessAbortMultipartUploadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareAbortMultipartUploadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uploadId: uploadId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareAbortMultipartUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uploadId: uploadId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessAbortMultipartUploadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AbortMultipartUpload", + methodName: "AbortMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/abort\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AbortMultipartUpload", + methodName: "AbortMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/abort\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AbortMultipartUpload", + methodName: "AbortMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/abort\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessAbortMultipartUploadResponseContent( + response: __response); + ProcessAbortMultipartUploadResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AbortMultipartUpload", + methodName: "AbortMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/abort\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "AbortMultipartUpload", + methodName: "AbortMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/abort\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessAbortMultipartUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CompleteMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CompleteMultipartUpload.g.cs index 8a79a26..fa3053f 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CompleteMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CompleteMultipartUpload.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,12 +52,14 @@ partial void ProcessCompleteMultipartUploadResponseContent( /// The ID of the multipart upload /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CompleteMultipartUploadAsync( global::System.Guid uploadId, global::Mixedbread.CompleteMultipartUploadRequest request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -74,22 +77,43 @@ partial void ProcessCompleteMultipartUploadResponseContent( securityRequirements: s_CompleteMultipartUploadSecurityRequirements, operationName: "CompleteMultipartUploadAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/uploads/{uploadId}/complete", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/uploads/{uploadId}/complete", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -99,157 +123,316 @@ partial void ProcessCompleteMultipartUploadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCompleteMultipartUploadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uploadId: uploadId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCompleteMultipartUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uploadId: uploadId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCompleteMultipartUploadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompleteMultipartUpload", + methodName: "CompleteMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/complete\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompleteMultipartUpload", + methodName: "CompleteMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/complete\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompleteMultipartUpload", + methodName: "CompleteMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/complete\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCompleteMultipartUploadResponseContent( + response: __response); + ProcessCompleteMultipartUploadResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompleteMultipartUpload", + methodName: "CompleteMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/complete\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CompleteMultipartUpload", + methodName: "CompleteMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}/complete\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCompleteMultipartUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Complete multipart upload
@@ -262,11 +445,13 @@ partial void ProcessCompleteMultipartUploadResponseContent( /// /// List of completed parts with their ETags /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CompleteMultipartUploadAsync( global::System.Guid uploadId, global::System.Collections.Generic.IList parts, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.CompleteMultipartUploadRequest @@ -277,6 +462,7 @@ partial void ProcessCompleteMultipartUploadResponseContent( return await CompleteMultipartUploadAsync( uploadId: uploadId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateFile.g.cs index ae27c1c..d260653 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateFile.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateFileResponseContent( /// FileResponse: The response containing the details of the uploaded file. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateFileAsync( global::Mixedbread.BodyCreateFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateFileResponseContent( securityRequirements: s_CreateFileSecurityRequirements, operationName: "CreateFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/files", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/files", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,161 +119,320 @@ partial void ProcessCreateFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - __httpRequest.Content = __httpRequestContent; + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateFile", + methodName: "CreateFileAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateFile", + methodName: "CreateFileAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateFile", + methodName: "CreateFileAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateFileResponseContent( + response: __response); + ProcessCreateFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateFile", + methodName: "CreateFileAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateFile", + methodName: "CreateFileAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Upload file
@@ -265,11 +448,13 @@ partial void ProcessCreateFileResponseContent( /// /// The file to upload /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateFileAsync( byte[] file, string filename, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.BodyCreateFile @@ -280,6 +465,7 @@ partial void ProcessCreateFileResponseContent( return await CreateFileAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateMultipartUpload.g.cs index 501849e..a13e7ee 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.CreateMultipartUpload.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -45,11 +46,13 @@ partial void ProcessCreateMultipartUploadResponseContent( /// Initiate a multipart upload and receive presigned URLs for uploading parts directly to storage. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateMultipartUploadAsync( global::Mixedbread.CreateMultipartUploadRequest request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -66,22 +69,43 @@ partial void ProcessCreateMultipartUploadResponseContent( securityRequirements: s_CreateMultipartUploadSecurityRequirements, operationName: "CreateMultipartUploadAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/files/uploads", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/files/uploads", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -91,156 +115,315 @@ partial void ProcessCreateMultipartUploadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateMultipartUploadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateMultipartUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateMultipartUploadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateMultipartUpload", + methodName: "CreateMultipartUploadAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateMultipartUpload", + methodName: "CreateMultipartUploadAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateMultipartUpload", + methodName: "CreateMultipartUploadAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateMultipartUploadResponseContent( + response: __response); + ProcessCreateMultipartUploadResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.CreateMultipartUploadResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateMultipartUpload", + methodName: "CreateMultipartUploadAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateMultipartUpload", + methodName: "CreateMultipartUploadAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.CreateMultipartUploadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateMultipartUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.CreateMultipartUploadResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.CreateMultipartUploadResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create multipart upload
@@ -259,6 +442,7 @@ partial void ProcessCreateMultipartUploadResponseContent( /// Number of parts to split the upload into
/// Default Value: 1 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateMultipartUploadAsync( @@ -266,6 +450,7 @@ partial void ProcessCreateMultipartUploadResponseContent( long fileSize, string mimeType, int? partCount = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.CreateMultipartUploadRequest @@ -278,6 +463,7 @@ partial void ProcessCreateMultipartUploadResponseContent( return await CreateMultipartUploadAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DeleteFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DeleteFile.g.cs index 7760692..ebe4db0 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DeleteFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DeleteFile.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDeleteFileResponseContent( /// /// The ID of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDeleteFileResponseContent( securityRequirements: s_DeleteFileSecurityRequirements, operationName: "DeleteFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/{fileId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/{fileId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessDeleteFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - fileId: fileId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + fileId: fileId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteFile", + methodName: "DeleteFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteFile", + methodName: "DeleteFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteFile", + methodName: "DeleteFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteFileResponseContent( + response: __response); + ProcessDeleteFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteFile", + methodName: "DeleteFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteFile", + methodName: "DeleteFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DownloadFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DownloadFile.g.cs index eed3594..e3951e7 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DownloadFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.DownloadFile.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDownloadFileResponseContent( /// /// The ID of the file to download /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DownloadFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDownloadFileResponseContent( securityRequirements: s_DownloadFileSecurityRequirements, operationName: "DownloadFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/{fileId}/content", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/{fileId}/content", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,141 +118,300 @@ partial void ProcessDownloadFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDownloadFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - fileId: fileId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDownloadFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + fileId: fileId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDownloadFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadFile", + methodName: "DownloadFileAsync", + pathTemplate: "$\"/v1/files/{fileId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadFile", + methodName: "DownloadFileAsync", + pathTemplate: "$\"/v1/files/{fileId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadFile", + methodName: "DownloadFileAsync", + pathTemplate: "$\"/v1/files/{fileId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessDownloadFileResponseContent( + ProcessResponse( + client: HttpClient, + response: __response); + ProcessDownloadFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return __content; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadFile", + methodName: "DownloadFileAsync", + pathTemplate: "$\"/v1/files/{fileId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DownloadFile", + methodName: "DownloadFileAsync", + pathTemplate: "$\"/v1/files/{fileId}/content\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsByteArrayAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return __content; - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessDownloadFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsByteArrayAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.GetMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.GetMultipartUpload.g.cs index 091b790..df7c18c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.GetMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.GetMultipartUpload.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -47,10 +48,12 @@ partial void ProcessGetMultipartUploadResponseContent( /// /// The ID of the multipart upload /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetMultipartUploadAsync( global::System.Guid uploadId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -65,22 +68,43 @@ partial void ProcessGetMultipartUploadResponseContent( securityRequirements: s_GetMultipartUploadSecurityRequirements, operationName: "GetMultipartUploadAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/uploads/{uploadId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/uploads/{uploadId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,150 +114,309 @@ partial void ProcessGetMultipartUploadResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetMultipartUploadRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - uploadId: uploadId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetMultipartUploadRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + uploadId: uploadId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetMultipartUploadResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMultipartUpload", + methodName: "GetMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMultipartUpload", + methodName: "GetMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMultipartUpload", + methodName: "GetMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetMultipartUploadResponseContent( + response: __response); + ProcessGetMultipartUploadResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MultipartUploadDetailResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMultipartUpload", + methodName: "GetMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMultipartUpload", + methodName: "GetMultipartUploadAsync", + pathTemplate: "$\"/v1/files/uploads/{uploadId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MultipartUploadDetailResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetMultipartUploadResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MultipartUploadDetailResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MultipartUploadDetailResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListFiles.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListFiles.g.cs index d473662..1cb89a1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListFiles.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListFiles.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -73,6 +74,7 @@ partial void ProcessListFilesResponseContent( /// /// Search query for fuzzy matching over name and description fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListFilesAsync( @@ -81,6 +83,7 @@ partial void ProcessListFilesResponseContent( string? before = default, bool? includeTotal = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -99,29 +102,50 @@ partial void ProcessListFilesResponseContent( securityRequirements: s_ListFilesSecurityRequirements, operationName: "ListFilesAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/files", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("q", q) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/files", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("q", q) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -131,154 +155,313 @@ partial void ProcessListFilesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListFilesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal, - q: q); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListFilesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal, + q: q); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListFilesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListFiles", + methodName: "ListFilesAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListFiles", + methodName: "ListFilesAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListFiles", + methodName: "ListFilesAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListFilesResponseContent( + response: __response); + ProcessListFilesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListFiles", + methodName: "ListFilesAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListFiles", + methodName: "ListFilesAsync", + pathTemplate: "\"/v1/files\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListFilesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListMultipartUploads.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListMultipartUploads.g.cs index 3c249ad..be5a7ec 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListMultipartUploads.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.ListMultipartUploads.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -42,9 +43,11 @@ partial void ProcessListMultipartUploadsResponseContent( /// List in-progress multipart uploads
/// List all in-progress multipart uploads for the authenticated organization. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListMultipartUploadsAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -58,22 +61,43 @@ partial void ProcessListMultipartUploadsResponseContent( securityRequirements: s_ListMultipartUploadsSecurityRequirements, operationName: "ListMultipartUploadsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/files/uploads", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/files/uploads", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -83,111 +107,270 @@ partial void ProcessListMultipartUploadsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListMultipartUploadsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListMultipartUploadsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListMultipartUploadsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListMultipartUploads", + methodName: "ListMultipartUploadsAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListMultipartUploads", + methodName: "ListMultipartUploadsAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessListMultipartUploadsResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListMultipartUploads", + methodName: "ListMultipartUploadsAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return - global::Mixedbread.MultipartUploadListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return - await global::Mixedbread.MultipartUploadListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); + ProcessResponse( + client: HttpClient, + response: __response); + ProcessListMultipartUploadsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListMultipartUploads", + methodName: "ListMultipartUploadsAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListMultipartUploads", + methodName: "ListMultipartUploadsAsync", + pathTemplate: "\"/v1/files/uploads\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListMultipartUploadsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MultipartUploadListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MultipartUploadListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.RetrieveFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.RetrieveFile.g.cs index 835a219..b8872df 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.RetrieveFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.RetrieveFile.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveFileResponseContent( /// /// The ID of the file to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveFileResponseContent( securityRequirements: s_RetrieveFileSecurityRequirements, operationName: "RetrieveFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/{fileId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/{fileId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRetrieveFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - fileId: fileId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + fileId: fileId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveFile", + methodName: "RetrieveFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveFile", + methodName: "RetrieveFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveFile", + methodName: "RetrieveFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveFileResponseContent( + response: __response); + ProcessRetrieveFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveFile", + methodName: "RetrieveFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveFile", + methodName: "RetrieveFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.UpdateFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.UpdateFile.g.cs index 8a447d1..aa7b920 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.UpdateFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.UpdateFile.g.cs @@ -14,6 +14,7 @@ public partial class FilesClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessUpdateFileResponseContent( /// The ID of the file to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateFileAsync( global::System.Guid fileId, global::Mixedbread.BodyUpdateFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessUpdateFileResponseContent( securityRequirements: s_UpdateFileSecurityRequirements, operationName: "UpdateFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/files/{fileId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/files/{fileId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,165 +127,324 @@ partial void ProcessUpdateFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{fileId}"), - name: "\"file_id\""); - var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - __httpRequest.Content = __httpRequestContent; + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{fileId}"), + name: "\"file_id\""); + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - fileId: fileId, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + fileId: fileId, + request: request); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateFile", + methodName: "UpdateFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateFile", + methodName: "UpdateFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateFile", + methodName: "UpdateFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateFileResponseContent( + response: __response); + ProcessUpdateFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateFile", + methodName: "UpdateFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateFile", + methodName: "UpdateFileAsync", + pathTemplate: "$\"/v1/files/{fileId}\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.FileObject.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.FileObject.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update file
@@ -281,12 +464,14 @@ partial void ProcessUpdateFileResponseContent( /// /// The file to update /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateFileAsync( global::System.Guid fileId, byte[] file, string filename, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.BodyUpdateFile @@ -298,6 +483,7 @@ partial void ProcessUpdateFileResponseContent( return await UpdateFileAsync( fileId: fileId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.g.cs index fa2f208..538e222 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.FilesClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class FilesClient : global::Mixedbread.IFilesClient, globa #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public FilesClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the FilesClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public FilesClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.ReingestAllStores.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.ReingestAllStores.g.cs index 7d3234c..6557b59 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.ReingestAllStores.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.ReingestAllStores.g.cs @@ -20,6 +20,7 @@ public partial interface IAdminClient /// Whether the reingestion is billable to the user
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ReingestAllStoresAsync( @@ -27,6 +28,7 @@ public partial interface IAdminClient string storeIdentifier, global::System.Collections.Generic.IList? statuses = default, bool? billable = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.g.cs index 55583c0..89f3eee 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IAdminClient.g.cs @@ -33,6 +33,11 @@ public partial interface IAdminClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.CreateApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.CreateApiKey.g.cs index b216d16..4c2b6e9 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.CreateApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.CreateApiKey.g.cs @@ -13,11 +13,13 @@ public partial interface IApiKeysClient /// ApiKeyCreated: The response containing the details of the created API key. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateApiKeyAsync( global::Mixedbread.ApiKeyCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create API key
@@ -37,12 +39,14 @@ public partial interface IApiKeysClient /// /// Optional expiration datetime /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateApiKeyAsync( string? name = default, global::System.Collections.Generic.IList? scope = default, global::System.DateTime? expiresAt = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.DeleteApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.DeleteApiKey.g.cs index ddd4071..0eb360c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.DeleteApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.DeleteApiKey.g.cs @@ -15,10 +15,12 @@ public partial interface IApiKeysClient /// /// The ID of the API key to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.ListApiKeys.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.ListApiKeys.g.cs index f89ce75..3fe7647 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.ListApiKeys.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.ListApiKeys.g.cs @@ -20,11 +20,13 @@ public partial interface IApiKeysClient /// Offset of the first item to return
/// Default Value: 0 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListApiKeysAsync( int? limit = default, int? offset = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RerollApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RerollApiKey.g.cs index 68885ad..22d9a65 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RerollApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RerollApiKey.g.cs @@ -16,10 +16,12 @@ public partial interface IApiKeysClient /// /// The ID of the API key to reroll /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RerollApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RetrieveApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RetrieveApiKey.g.cs index 1792e8b..e7923c3 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RetrieveApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RetrieveApiKey.g.cs @@ -15,10 +15,12 @@ public partial interface IApiKeysClient /// /// The ID of the API key to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RevokeApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RevokeApiKey.g.cs index 2671388..901e9ad 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RevokeApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.RevokeApiKey.g.cs @@ -15,10 +15,12 @@ public partial interface IApiKeysClient /// /// The ID of the API key to revoke /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RevokeApiKeyAsync( global::System.Guid apiKeyId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.UpdateApiKey.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.UpdateApiKey.g.cs index 1905acc..b41c74b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.UpdateApiKey.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.UpdateApiKey.g.cs @@ -17,12 +17,14 @@ public partial interface IApiKeysClient /// The ID of the API key to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateApiKeyAsync( global::System.Guid apiKeyId, global::Mixedbread.ApiKeyUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update API key
@@ -42,12 +44,14 @@ public partial interface IApiKeysClient /// /// Optional expiration datetime /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateApiKeyAsync( global::System.Guid apiKeyId, string? name = default, global::System.DateTime? expiresAt = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.g.cs index faf2668..727ba7e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IApiKeysClient.g.cs @@ -33,6 +33,11 @@ public partial interface IApiKeysClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetBillingSummary.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetBillingSummary.g.cs index 45aaa52..a3207ff 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetBillingSummary.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetBillingSummary.g.cs @@ -7,9 +7,11 @@ public partial interface IBillingClient /// /// Get billing summary /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetBillingSummaryAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetParsingCostHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetParsingCostHistogram.g.cs index 276d268..0bd7f56 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetParsingCostHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetParsingCostHistogram.g.cs @@ -7,9 +7,11 @@ public partial interface IBillingClient /// /// Get parsing cost histogram /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetParsingCostHistogramAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetStoreCostHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetStoreCostHistogram.g.cs index d09c318..05e85df 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetStoreCostHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.GetStoreCostHistogram.g.cs @@ -10,10 +10,12 @@ public partial interface IBillingClient /// /// The ID of the store /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetStoreCostHistogramAsync( global::System.Guid storeId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.ListStoreCostInfo.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.ListStoreCostInfo.g.cs index 9d5f14c..bf4691c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.ListStoreCostInfo.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.ListStoreCostInfo.g.cs @@ -7,9 +7,11 @@ public partial interface IBillingClient /// /// List store cost information /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListStoreCostInfoAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.g.cs index ca66cd0..03ff268 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IBillingClient.g.cs @@ -33,6 +33,11 @@ public partial interface IBillingClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.CreateChatCompletion.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.CreateChatCompletion.g.cs index f571e45..aad6780 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.CreateChatCompletion.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.CreateChatCompletion.g.cs @@ -18,9 +18,11 @@ public partial interface ICompletionsClient /// Raises:
/// HTTPException: If there is an error creating the completion (500) ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateChatCompletionAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.g.cs index e2a3100..a618b23 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ICompletionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface ICompletionsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.AuthorizeDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.AuthorizeDataSource.g.cs index de8a577..34658ca 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.AuthorizeDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.AuthorizeDataSource.g.cs @@ -21,10 +21,12 @@ public partial interface IDataSourcesClient /// /// The ID of the data source to authorize /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task AuthorizeDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateConnector.g.cs index af4efca..6169ac4 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateConnector.g.cs @@ -17,12 +17,14 @@ public partial interface IDataSourcesClient /// The ID of the data source to create a connector for /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateConnectorAsync( global::System.Guid dataSourceId, global::Mixedbread.DataSourceConnectorCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new connector
@@ -56,6 +58,7 @@ public partial interface IDataSourcesClient /// - str: Duration string (e.g., '30m', '1h', '2d') or ISO 8601 format (e.g., 'PT30M', 'P1D')
/// Valid range: 15 seconds to 30 days /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateConnectorAsync( @@ -65,6 +68,7 @@ public partial interface IDataSourcesClient bool? triggerSync = default, object? metadata = default, global::Mixedbread.AnyOf? pollingInterval = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateDataSource.g.cs index 1cfe504..529a559 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.CreateDataSource.g.cs @@ -13,11 +13,13 @@ public partial interface IDataSourcesClient /// The created data source. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateDataSourceAsync( global::Mixedbread.AnyOf request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a new data source
@@ -27,9 +29,11 @@ public partial interface IDataSourcesClient /// Returns:
/// The created data source. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateDataSourceAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteConnector.g.cs index ae2dfa5..72332a7 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteConnector.g.cs @@ -19,11 +19,13 @@ public partial interface IDataSourcesClient /// /// The ID of the connector to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteConnectorAsync( global::System.Guid dataSourceId, global::System.Guid connectorId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteDataSource.g.cs index 02de0a2..487ef48 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.DeleteDataSource.g.cs @@ -13,10 +13,12 @@ public partial interface IDataSourcesClient /// /// The ID of the data source to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetConnector.g.cs index 2025f0b..2008dfc 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetConnector.g.cs @@ -19,11 +19,13 @@ public partial interface IDataSourcesClient /// /// The ID of the connector to get /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetConnectorAsync( global::System.Guid dataSourceId, global::System.Guid connectorId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetDataSource.g.cs index aedf29a..1848464 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.GetDataSource.g.cs @@ -15,10 +15,12 @@ public partial interface IDataSourcesClient /// /// The ID of the data source to fetch /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListConnectors.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListConnectors.g.cs index ef9d971..69798ac 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListConnectors.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListConnectors.g.cs @@ -30,6 +30,7 @@ public partial interface IDataSourcesClient /// Whether to include total count in response (expensive operation)
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListConnectorsAsync( @@ -38,6 +39,7 @@ public partial interface IDataSourcesClient string? after = default, string? before = default, bool? includeTotal = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListDataSources.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListDataSources.g.cs index 5541b34..049484a 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListDataSources.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.ListDataSources.g.cs @@ -24,6 +24,7 @@ public partial interface IDataSourcesClient /// Whether to include total count in response (expensive operation)
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListDataSourcesAsync( @@ -31,6 +32,7 @@ public partial interface IDataSourcesClient string? after = default, string? before = default, bool? includeTotal = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.Oauth2Callback.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.Oauth2Callback.g.cs index f359def..5be500e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.Oauth2Callback.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.Oauth2Callback.g.cs @@ -33,6 +33,7 @@ public partial interface IDataSourcesClient /// /// Human-readable error description /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task Oauth2CallbackAsync( @@ -40,6 +41,7 @@ public partial interface IDataSourcesClient string code, string? error = default, string? errorDescription = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateConnector.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateConnector.g.cs index 23dc140..ad2291c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateConnector.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateConnector.g.cs @@ -21,6 +21,7 @@ public partial interface IDataSourcesClient /// The ID of the connector to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateConnectorAsync( @@ -28,6 +29,7 @@ public partial interface IDataSourcesClient global::System.Guid connectorId, global::Mixedbread.DataSourceConnectorUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a connector
@@ -60,6 +62,7 @@ public partial interface IDataSourcesClient /// - str: Duration string (e.g., '30m', '1h', '2d') or ISO 8601 format (e.g., 'PT30M', 'P1D')
/// Valid range: 15 seconds to 30 days /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateConnectorAsync( @@ -69,6 +72,7 @@ public partial interface IDataSourcesClient object? metadata = default, bool? triggerSync = default, global::Mixedbread.AnyOf? pollingInterval = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateDataSource.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateDataSource.g.cs index 3dd582b..52104e7 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateDataSource.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.UpdateDataSource.g.cs @@ -17,12 +17,14 @@ public partial interface IDataSourcesClient /// The ID of the data source to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateDataSourceAsync( global::System.Guid dataSourceId, global::Mixedbread.AnyOf request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a data source
@@ -36,10 +38,12 @@ public partial interface IDataSourcesClient /// /// The ID of the data source to update /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateDataSourceAsync( global::System.Guid dataSourceId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.g.cs index f039841..655fb22 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IDataSourcesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IDataSourcesClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateExtractionJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateExtractionJob.g.cs index 65c1973..e883c28 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateExtractionJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateExtractionJob.g.cs @@ -13,11 +13,13 @@ public partial interface IExtractionsClient /// The created extraction job. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateExtractionJobAsync( global::Mixedbread.ExtractJobCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Start an extraction job
@@ -33,11 +35,13 @@ public partial interface IExtractionsClient /// /// The JSON schema to use for extraction /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateExtractionJobAsync( string fileId, object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateSchema.g.cs index 39944b2..f89ebdc 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.CreateSchema.g.cs @@ -13,11 +13,13 @@ public partial interface IExtractionsClient /// The created schema. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateSchemaAsync( global::Mixedbread.JsonSchemaCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a schema
@@ -30,10 +32,12 @@ public partial interface IExtractionsClient /// /// Description of the data to extract /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateSchemaAsync( string description, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.EnhanceSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.EnhanceSchema.g.cs index cf91fc8..605d72a 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.EnhanceSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.EnhanceSchema.g.cs @@ -13,11 +13,13 @@ public partial interface IExtractionsClient /// The enhanced schema. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task EnhanceSchemaAsync( global::Mixedbread.JsonSchemaEnhanceParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Enhance a schema
@@ -30,10 +32,12 @@ public partial interface IExtractionsClient /// /// The JSON schema to enhance /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task EnhanceSchemaAsync( object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ExtractContent.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ExtractContent.g.cs index c25420a..faeca08 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ExtractContent.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ExtractContent.g.cs @@ -13,11 +13,13 @@ public partial interface IExtractionsClient /// The extracted content. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ExtractContentAsync( global::Mixedbread.ExtractContentCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Extract content from a string
@@ -36,12 +38,14 @@ public partial interface IExtractionsClient /// /// Additional instructions for the extraction /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ExtractContentAsync( global::Mixedbread.AnyOf, global::System.Collections.Generic.IList>> content, object jsonSchema, string? instructions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.RetrieveExtractionJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.RetrieveExtractionJob.g.cs index b96d1a3..4fb2581 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.RetrieveExtractionJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.RetrieveExtractionJob.g.cs @@ -15,10 +15,12 @@ public partial interface IExtractionsClient /// /// The ID of the extraction job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveExtractionJobAsync( string jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ValidateSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ValidateSchema.g.cs index 2286edb..2fbd5bb 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ValidateSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.ValidateSchema.g.cs @@ -13,11 +13,13 @@ public partial interface IExtractionsClient /// The validation result. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ValidateSchemaAsync( global::Mixedbread.JsonSchemaValidateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Validate a schema
@@ -30,10 +32,12 @@ public partial interface IExtractionsClient /// /// The JSON schema to validate /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ValidateSchemaAsync( object jsonSchema, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.g.cs index 705f678..6e28d01 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IExtractionsClient.g.cs @@ -33,6 +33,11 @@ public partial interface IExtractionsClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.AbortMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.AbortMultipartUpload.g.cs index b3014c7..8e82828 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.AbortMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.AbortMultipartUpload.g.cs @@ -11,10 +11,12 @@ public partial interface IFilesClient /// /// The ID of the multipart upload to abort /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task AbortMultipartUploadAsync( global::System.Guid uploadId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CompleteMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CompleteMultipartUpload.g.cs index 9354cda..eebe4d2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CompleteMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CompleteMultipartUpload.g.cs @@ -13,12 +13,14 @@ public partial interface IFilesClient /// The ID of the multipart upload /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CompleteMultipartUploadAsync( global::System.Guid uploadId, global::Mixedbread.CompleteMultipartUploadRequest request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Complete multipart upload
@@ -31,11 +33,13 @@ public partial interface IFilesClient /// /// List of completed parts with their ETags /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CompleteMultipartUploadAsync( global::System.Guid uploadId, global::System.Collections.Generic.IList parts, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateFile.g.cs index 4afdc7c..de67243 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateFile.g.cs @@ -13,11 +13,13 @@ public partial interface IFilesClient /// FileResponse: The response containing the details of the uploaded file. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateFileAsync( global::Mixedbread.BodyCreateFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Upload file
@@ -33,11 +35,13 @@ public partial interface IFilesClient /// /// The file to upload /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateFileAsync( byte[] file, string filename, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateMultipartUpload.g.cs index 2b862bb..c9865fa 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.CreateMultipartUpload.g.cs @@ -9,11 +9,13 @@ public partial interface IFilesClient /// Initiate a multipart upload and receive presigned URLs for uploading parts directly to storage. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateMultipartUploadAsync( global::Mixedbread.CreateMultipartUploadRequest request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create multipart upload
@@ -32,6 +34,7 @@ public partial interface IFilesClient /// Number of parts to split the upload into
/// Default Value: 1 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateMultipartUploadAsync( @@ -39,6 +42,7 @@ public partial interface IFilesClient long fileSize, string mimeType, int? partCount = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DeleteFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DeleteFile.g.cs index ef00f58..aa765e6 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DeleteFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DeleteFile.g.cs @@ -15,10 +15,12 @@ public partial interface IFilesClient /// /// The ID of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DownloadFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DownloadFile.g.cs index 2af8b6d..b2e16d5 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DownloadFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.DownloadFile.g.cs @@ -15,10 +15,12 @@ public partial interface IFilesClient /// /// The ID of the file to download /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DownloadFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.GetMultipartUpload.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.GetMultipartUpload.g.cs index 6871e56..b05afb9 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.GetMultipartUpload.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.GetMultipartUpload.g.cs @@ -11,10 +11,12 @@ public partial interface IFilesClient /// /// The ID of the multipart upload /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetMultipartUploadAsync( global::System.Guid uploadId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListFiles.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListFiles.g.cs index 6e63e59..96d950f 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListFiles.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListFiles.g.cs @@ -29,6 +29,7 @@ public partial interface IFilesClient /// /// Search query for fuzzy matching over name and description fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListFilesAsync( @@ -37,6 +38,7 @@ public partial interface IFilesClient string? before = default, bool? includeTotal = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListMultipartUploads.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListMultipartUploads.g.cs index 47f47e2..c070788 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListMultipartUploads.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.ListMultipartUploads.g.cs @@ -8,9 +8,11 @@ public partial interface IFilesClient /// List in-progress multipart uploads
/// List all in-progress multipart uploads for the authenticated organization. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListMultipartUploadsAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.RetrieveFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.RetrieveFile.g.cs index bd9d99a..cef7227 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.RetrieveFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.RetrieveFile.g.cs @@ -15,10 +15,12 @@ public partial interface IFilesClient /// /// The ID of the file to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveFileAsync( global::System.Guid fileId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.UpdateFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.UpdateFile.g.cs index 7d57826..5c70a7e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.UpdateFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.UpdateFile.g.cs @@ -17,12 +17,14 @@ public partial interface IFilesClient /// The ID of the file to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateFileAsync( global::System.Guid fileId, global::Mixedbread.BodyUpdateFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update file
@@ -42,12 +44,14 @@ public partial interface IFilesClient /// /// The file to update /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateFileAsync( global::System.Guid fileId, byte[] file, string filename, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.g.cs index 85c3006..4f30aa7 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IFilesClient.g.cs @@ -33,6 +33,11 @@ public partial interface IFilesClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.CreateEmbeddings.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.CreateEmbeddings.g.cs index 3daf253..67d0de2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.CreateEmbeddings.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.CreateEmbeddings.g.cs @@ -13,11 +13,13 @@ public partial interface IMixedbreadClient /// EmbeddingCreateResponse: The response containing the embeddings. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateEmbeddingsAsync( global::Mixedbread.EmbeddingCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create embeddings for text and images
@@ -47,6 +49,7 @@ public partial interface IMixedbreadClient /// The encoding format(s) of the embeddings. Can be a single format or a list of formats.
/// Default Value: float /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateEmbeddingsAsync( @@ -56,6 +59,7 @@ public partial interface IMixedbreadClient string? prompt = default, bool? normalized = default, global::Mixedbread.AnyOf>? encodingFormat = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Info.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Info.g.cs index 3b7b918..5c81300 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Info.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Info.g.cs @@ -10,9 +10,11 @@ public partial interface IMixedbreadClient /// Returns:
/// InfoResponse: A response containing the service name and version. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task InfoAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Rerank.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Rerank.g.cs index 10994b3..2d213d9 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Rerank.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.Rerank.g.cs @@ -13,11 +13,13 @@ public partial interface IMixedbreadClient /// RerankResponse: The reranked documents for the input query. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RerankAsync( global::Mixedbread.RerankParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Rerank different kind of documents for a given query
@@ -52,6 +54,7 @@ public partial interface IMixedbreadClient /// Wether or not to rewrite the query before passing it to the reranking model
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RerankAsync( @@ -62,6 +65,7 @@ public partial interface IMixedbreadClient int? topK = default, bool? returnInput = default, bool? rewriteQuery = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.g.cs index 471794b..e0b5af2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IMixedbreadClient.g.cs @@ -33,6 +33,11 @@ public partial interface IMixedbreadClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CancelParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CancelParsingJob.g.cs index 322d5f7..e85a3b2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CancelParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CancelParsingJob.g.cs @@ -15,10 +15,12 @@ public partial interface IParsingClient /// /// The ID of the parse job to cancel /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CancelParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CreateParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CreateParsingJob.g.cs index 2f690ed..2edbf59 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CreateParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.CreateParsingJob.g.cs @@ -13,11 +13,13 @@ public partial interface IParsingClient /// The created parsing job. /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateParsingJobAsync( global::Mixedbread.ParsingJobCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Start a parse job
@@ -45,6 +47,7 @@ public partial interface IParsingClient /// The strategy to use for OCR
/// Default Value: high_quality /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateParsingJobAsync( @@ -53,6 +56,7 @@ public partial interface IParsingClient global::Mixedbread.ChunkingStrategy? chunkingStrategy = default, global::Mixedbread.ReturnFormat? returnFormat = default, global::Mixedbread.Mode? mode = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.DeleteParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.DeleteParsingJob.g.cs index f24363c..60ad068 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.DeleteParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.DeleteParsingJob.g.cs @@ -15,10 +15,12 @@ public partial interface IParsingClient /// /// The ID of the parse job to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.ListParsingJobs.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.ListParsingJobs.g.cs index 4daca95..1c623b1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.ListParsingJobs.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.ListParsingJobs.g.cs @@ -33,6 +33,7 @@ public partial interface IParsingClient /// /// Search query to filter by /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListParsingJobsAsync( @@ -42,6 +43,7 @@ public partial interface IParsingClient bool? includeTotal = default, global::System.Collections.Generic.IList? statuses = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.RetrieveParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.RetrieveParsingJob.g.cs index 03193e9..7b4e223 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.RetrieveParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.RetrieveParsingJob.g.cs @@ -15,10 +15,12 @@ public partial interface IParsingClient /// /// The ID of the parse job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.g.cs index 7633e0a..329daf1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IParsingClient.g.cs @@ -33,6 +33,11 @@ public partial interface IParsingClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.GetMxbaiJsonSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.GetMxbaiJsonSchema.g.cs index f645010..168ddfb 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.GetMxbaiJsonSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.GetMxbaiJsonSchema.g.cs @@ -10,9 +10,11 @@ public partial interface ISchemasClient /// Returns:
/// The mxbai json schema. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetMxbaiJsonSchemaAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.g.cs index f384659..7bd8d03 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ISchemasClient.g.cs @@ -33,6 +33,11 @@ public partial interface ISchemasClient : global::System.IDisposable /// public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateQuestionAnswering.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateQuestionAnswering.g.cs index dc72012..c0a107c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateQuestionAnswering.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateQuestionAnswering.g.cs @@ -8,11 +8,13 @@ public partial interface IStoresClient /// Question answering /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateQuestionAnsweringAsync( global::Mixedbread.StoreQAParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Question answering @@ -46,6 +48,7 @@ public partial interface IStoresClient /// /// Question answering configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateQuestionAnsweringAsync( @@ -58,6 +61,7 @@ public partial interface IStoresClient bool? stream = default, string? instructions = default, global::Mixedbread.QuestionAnsweringOptions? qaOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateSearchRule.g.cs index c2dee75..e60784c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateSearchRule.g.cs @@ -17,12 +17,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create search rule
@@ -42,12 +44,14 @@ public partial interface IStoresClient /// /// The rules to apply on query matches /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, string query, global::System.Collections.Generic.IList rules, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStore.g.cs index f26bddd..3ff8c20 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStore.g.cs @@ -13,11 +13,13 @@ public partial interface IStoresClient /// VectorStore: The response containing the created vector store details. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateStoreAsync( global::Mixedbread.StoreCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Create a store
@@ -49,6 +51,7 @@ public partial interface IStoresClient /// /// Optional list of file IDs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateStoreAsync( @@ -59,6 +62,7 @@ public partial interface IStoresClient object? metadata = default, global::Mixedbread.StoreConfig2? config = default, global::System.Collections.Generic.IList? fileIds = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStoreFile.g.cs index 32edcaf..682c53d 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.CreateStoreFile.g.cs @@ -19,12 +19,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.DeprecatedStoreFileUpsertParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Upload file to store
@@ -54,6 +56,7 @@ public partial interface IStoresClient /// /// ID of the file to add /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task CreateStoreFileAsync( @@ -63,6 +66,7 @@ public partial interface IStoresClient global::Mixedbread.StoreFileConfig2? config = default, string? externalId = default, bool? overwrite = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSearchRule.g.cs index ae764f1..73c5d36 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSearchRule.g.cs @@ -19,11 +19,13 @@ public partial interface IStoresClient /// /// The ID of the search rule to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSpecificSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSpecificSearchRule.g.cs index cde3efb..58f540b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSpecificSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteSpecificSearchRule.g.cs @@ -21,6 +21,7 @@ public partial interface IStoresClient /// The ID of the search rule /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteSpecificSearchRuleAsync( @@ -28,6 +29,7 @@ public partial interface IStoresClient global::System.Guid ruleId, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleteParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Delete a specific rule from rules array
@@ -48,12 +50,14 @@ public partial interface IStoresClient /// /// The specific rule to delete from the rules array /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteSpecificSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, global::Mixedbread.Rule2 rule, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStore.g.cs index f95ea3c..9c8f5ab 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStore.g.cs @@ -15,10 +15,12 @@ public partial interface IStoresClient /// /// The ID or name of the store to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteStoreAsync( global::Mixedbread.AnyOf storeIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStoreFile.g.cs index b5ad511..3c39f28 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.DeleteStoreFile.g.cs @@ -19,11 +19,13 @@ public partial interface IStoresClient /// /// The ID or name of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task DeleteStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetMetadataFacets.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetMetadataFacets.g.cs index 0296b14..4ee6260 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetMetadataFacets.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetMetadataFacets.g.cs @@ -8,11 +8,13 @@ public partial interface IStoresClient /// Get metadata facets ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetMetadataFacetsAsync( global::Mixedbread.MetadataFacetsParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Get metadata facets @@ -39,6 +41,7 @@ public partial interface IStoresClient /// /// Optional list of facets to return. Use dot for nested fields. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetMetadataFacetsAsync( @@ -49,6 +52,7 @@ public partial interface IStoresClient global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreChunkSearchOptions? searchOptions = default, global::System.Collections.Generic.IList? facets = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetStoreEventHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetStoreEventHistogram.g.cs index 8d16156..6983bcc 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetStoreEventHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.GetStoreEventHistogram.g.cs @@ -17,12 +17,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetStoreEventHistogramAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.StoreEventHistogramParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Get store event histogram
@@ -46,6 +48,7 @@ public partial interface IStoresClient /// Number of seconds in each bucket
/// Default Value: 7200 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task GetStoreEventHistogramAsync( @@ -53,6 +56,7 @@ public partial interface IStoresClient global::System.DateTime? startTime = default, global::System.DateTime? endTime = default, int? bucketSeconds = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreEvents.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreEvents.g.cs index 8b426ba..a2c4cac 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreEvents.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreEvents.g.cs @@ -39,6 +39,7 @@ public partial interface IStoresClient /// /// The type of event to list /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListStoreEventsAsync( @@ -50,6 +51,7 @@ public partial interface IStoresClient bool? includeTotal = default, global::System.DateTime? filterBefore = default, global::System.DateTime? filterAfter = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreFilesWithMetadataFilter.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreFilesWithMetadataFilter.g.cs index a6f678a..00e863f 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreFilesWithMetadataFilter.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStoreFilesWithMetadataFilter.g.cs @@ -17,12 +17,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListStoreFilesWithMetadataFilterAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.SearchCursorPagination request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// List store files with metadata filter
@@ -59,6 +61,7 @@ public partial interface IStoresClient /// /// Search query for fuzzy matching over name and external_id fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListStoreFilesWithMetadataFilterAsync( @@ -70,6 +73,7 @@ public partial interface IStoresClient global::System.Collections.Generic.IList? statuses = default, global::Mixedbread.AnyOf>, object>? metadataFilter = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStores.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStores.g.cs index 27d2371..fd81356 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStores.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.ListStores.g.cs @@ -30,6 +30,7 @@ public partial interface IStoresClient /// /// Search query for fuzzy matching over name and description fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task ListStoresAsync( @@ -38,6 +39,7 @@ public partial interface IStoresClient string? before = default, bool? includeTotal = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveSearchRule.g.cs index 9aa838d..3c5225a 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveSearchRule.g.cs @@ -19,11 +19,13 @@ public partial interface IStoresClient /// /// The ID of the search rule /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStore.g.cs index 4afc8f6..9664486 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStore.g.cs @@ -15,10 +15,12 @@ public partial interface IStoresClient /// /// The ID or name of the store /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveStoreAsync( global::Mixedbread.AnyOf storeIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStoreFile.g.cs index af11b09..ac22486 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.RetrieveStoreFile.g.cs @@ -24,12 +24,14 @@ public partial interface IStoresClient /// Whether to return the chunks for the file. If a list of integers is provided, only the chunks at the specified indices will be returned.
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task RetrieveStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, global::Mixedbread.AnyOf>? returnChunks = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreChunks.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreChunks.g.cs index f04cbe5..a746474 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreChunks.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreChunks.g.cs @@ -31,11 +31,13 @@ public partial interface IStoresClient /// HTTPException (404): If no vector stores are found to search ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task SearchStoreChunksAsync( global::Mixedbread.StoreChunkSearchParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Perform semantic search across store chunks
@@ -82,6 +84,7 @@ public partial interface IStoresClient /// /// Search configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task SearchStoreChunksAsync( @@ -91,6 +94,7 @@ public partial interface IStoresClient global::Mixedbread.AnyOf>, object>? filters = default, global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreChunkSearchOptions? searchOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreFiles.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreFiles.g.cs index fb83a6c..9238d8b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreFiles.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.SearchStoreFiles.g.cs @@ -14,11 +14,13 @@ public partial interface IStoresClient /// StoreFileSearchResponse: List of matching files with relevance scores ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task SearchStoreFilesAsync( global::Mixedbread.StoreFileSearchParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Search store files
@@ -48,6 +50,7 @@ public partial interface IStoresClient /// /// Search configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task SearchStoreFilesAsync( @@ -57,6 +60,7 @@ public partial interface IStoresClient global::Mixedbread.AnyOf>, object>? filters = default, global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreFileSearchOptions? searchOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateSearchRule.g.cs index 411518d..8b6e1ce 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateSearchRule.g.cs @@ -21,6 +21,7 @@ public partial interface IStoresClient /// The ID of the search rule to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateSearchRuleAsync( @@ -28,6 +29,7 @@ public partial interface IStoresClient global::System.Guid ruleId, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a search rule
@@ -51,6 +53,7 @@ public partial interface IStoresClient /// /// The rules to apply on query matches /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateSearchRuleAsync( @@ -58,6 +61,7 @@ public partial interface IStoresClient global::System.Guid ruleId, string? query = default, global::System.Collections.Generic.IList? rules = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStore.g.cs index 72c924b..074e9a6 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStore.g.cs @@ -17,12 +17,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateStoreAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.StoreUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update a store
@@ -51,6 +53,7 @@ public partial interface IStoresClient /// /// Optional metadata key-value pairs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateStoreAsync( @@ -60,6 +63,7 @@ public partial interface IStoresClient bool? isPublic = default, global::Mixedbread.ExpiresAfter? expiresAfter = default, object? metadata = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStoreFile.g.cs index 0c59edc..ef6f218 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UpdateStoreFile.g.cs @@ -21,6 +21,7 @@ public partial interface IStoresClient /// The ID or name of the file to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateStoreFileAsync( @@ -28,6 +29,7 @@ public partial interface IStoresClient global::Mixedbread.AnyOf fileIdentifier, global::Mixedbread.StoreFileMetadataUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Update store file metadata
@@ -48,12 +50,14 @@ public partial interface IStoresClient /// /// Updated metadata for the file /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UpdateStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, object? metadata = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UploadStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UploadStoreFile.g.cs index f1a6896..4577913 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UploadStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.UploadStoreFile.g.cs @@ -19,12 +19,14 @@ public partial interface IStoresClient /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UploadStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.BodyUploadStoreFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); /// /// Upload file via form to store
@@ -47,6 +49,7 @@ public partial interface IStoresClient /// The file to upload and index /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// global::System.Threading.Tasks.Task UploadStoreFileAsync( @@ -54,6 +57,7 @@ public partial interface IStoresClient byte[] file, string filename, string? @params = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.g.cs index eaac466..2ea4c85 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.IStoresClient.g.cs @@ -33,6 +33,11 @@ public partial interface IStoresClient : global::System.IDisposable ///
public bool ReadResponseAsString { get; set; } + /// + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Authorizations.Bearer.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Authorizations.Bearer.g.cs index 4633d35..535ab84 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Authorizations.Bearer.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Authorizations.Bearer.g.cs @@ -25,6 +25,7 @@ public void AuthorizeUsingBearer( Authorizations.Add(new global::Mixedbread.EndPointAuthorization { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", Value = apiKey, diff --git a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.CreateEmbeddings.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.CreateEmbeddings.g.cs index b65f107..1247c62 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.CreateEmbeddings.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.CreateEmbeddings.g.cs @@ -14,6 +14,7 @@ public partial class MixedbreadClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateEmbeddingsResponseContent( /// EmbeddingCreateResponse: The response containing the embeddings. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateEmbeddingsAsync( global::Mixedbread.EmbeddingCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateEmbeddingsResponseContent( securityRequirements: s_CreateEmbeddingsSecurityRequirements, operationName: "CreateEmbeddingsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/embeddings", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/embeddings", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateEmbeddingsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateEmbeddingsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateEmbeddingsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateEmbeddingsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEmbeddings", + methodName: "CreateEmbeddingsAsync", + pathTemplate: "\"/v1/embeddings\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEmbeddings", + methodName: "CreateEmbeddingsAsync", + pathTemplate: "\"/v1/embeddings\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEmbeddings", + methodName: "CreateEmbeddingsAsync", + pathTemplate: "\"/v1/embeddings\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateEmbeddingsResponseContent( + response: __response); + ProcessCreateEmbeddingsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.EmbeddingCreateResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEmbeddings", + methodName: "CreateEmbeddingsAsync", + pathTemplate: "\"/v1/embeddings\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateEmbeddings", + methodName: "CreateEmbeddingsAsync", + pathTemplate: "\"/v1/embeddings\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.EmbeddingCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateEmbeddingsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.EmbeddingCreateResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.EmbeddingCreateResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create embeddings for text and images
@@ -274,6 +457,7 @@ partial void ProcessCreateEmbeddingsResponseContent( /// The encoding format(s) of the embeddings. Can be a single format or a list of formats.
/// Default Value: float /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateEmbeddingsAsync( @@ -283,6 +467,7 @@ partial void ProcessCreateEmbeddingsResponseContent( string? prompt = default, bool? normalized = default, global::Mixedbread.AnyOf>? encodingFormat = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.EmbeddingCreateParams @@ -297,6 +482,7 @@ partial void ProcessCreateEmbeddingsResponseContent( return await CreateEmbeddingsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Info.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Info.g.cs index 2e9a475..45d7fd4 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Info.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Info.g.cs @@ -14,6 +14,7 @@ public partial class MixedbreadClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,9 +45,11 @@ partial void ProcessInfoResponseContent( /// Returns:
/// InfoResponse: A response containing the service name and version. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task InfoAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -60,22 +63,43 @@ partial void ProcessInfoResponseContent( securityRequirements: s_InfoSecurityRequirements, operationName: "InfoAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -85,149 +109,308 @@ partial void ProcessInfoResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareInfoRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareInfoRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); - - ProcessResponse( - client: HttpClient, - response: __response); - ProcessInfoResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Info failed - if ((int)__response.StatusCode == 500) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_500 = null; - global::System.Exception? __exception_500 = null; - global::Mixedbread.ErrorResponse? __value_500 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_500 = global::Mixedbread.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_500 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_500 = global::Mixedbread.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_500 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_500, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_500, - ResponseObject = __value_500, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessInfoResponseContent( + response: __response); + ProcessInfoResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.InfoResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Info", + methodName: "InfoAsync", + pathTemplate: "\"/\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Info failed + if ((int)__response.StatusCode == 500) + { + string? __content_500 = null; + global::System.Exception? __exception_500 = null; + global::Mixedbread.ErrorResponse? __value_500 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_500 = global::Mixedbread.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + else + { + __content_500 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.InfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_500 = global::Mixedbread.ErrorResponse.FromJson(__content_500, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_500 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_500 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_500, + statusCode: __response.StatusCode) + { + ResponseBody = __content_500, + ResponseObject = __value_500, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessInfoResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.InfoResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.InfoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Rerank.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Rerank.g.cs index 71fbc25..0850227 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Rerank.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.Rerank.g.cs @@ -14,6 +14,7 @@ public partial class MixedbreadClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessRerankResponseContent( /// RerankResponse: The reranked documents for the input query. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RerankAsync( global::Mixedbread.RerankParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessRerankResponseContent( securityRequirements: s_RerankSecurityRequirements, operationName: "RerankAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/reranking", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/reranking", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessRerankResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRerankRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRerankRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRerankResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/v1/reranking\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/v1/reranking\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/v1/reranking\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRerankResponseContent( + response: __response); + ProcessRerankResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.RerankResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/v1/reranking\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "Rerank", + methodName: "RerankAsync", + pathTemplate: "\"/v1/reranking\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.RerankResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRerankResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.RerankResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.RerankResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Rerank different kind of documents for a given query
@@ -279,6 +462,7 @@ partial void ProcessRerankResponseContent( /// Wether or not to rewrite the query before passing it to the reranking model
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RerankAsync( @@ -289,6 +473,7 @@ partial void ProcessRerankResponseContent( int? topK = default, bool? returnInput = default, bool? rewriteQuery = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.RerankParams @@ -304,6 +489,7 @@ partial void ProcessRerankResponseContent( return await RerankAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.g.cs index 6cddf49..f991019 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.MixedbreadClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -39,7 +42,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public AdminClient Admin => new AdminClient(HttpClient, authorizations: Authorizations) + public AdminClient Admin => new AdminClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -48,7 +51,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public ApiKeysClient ApiKeys => new ApiKeysClient(HttpClient, authorizations: Authorizations) + public ApiKeysClient ApiKeys => new ApiKeysClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -57,7 +60,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public BillingClient Billing => new BillingClient(HttpClient, authorizations: Authorizations) + public BillingClient Billing => new BillingClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -66,7 +69,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public CompletionsClient Completions => new CompletionsClient(HttpClient, authorizations: Authorizations) + public CompletionsClient Completions => new CompletionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -75,7 +78,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public DataSourcesClient DataSources => new DataSourcesClient(HttpClient, authorizations: Authorizations) + public DataSourcesClient DataSources => new DataSourcesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -84,7 +87,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public ExtractionsClient Extractions => new ExtractionsClient(HttpClient, authorizations: Authorizations) + public ExtractionsClient Extractions => new ExtractionsClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -93,7 +96,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public FilesClient Files => new FilesClient(HttpClient, authorizations: Authorizations) + public FilesClient Files => new FilesClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -102,7 +105,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public ParsingClient Parsing => new ParsingClient(HttpClient, authorizations: Authorizations) + public ParsingClient Parsing => new ParsingClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -111,7 +114,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public SchemasClient Schemas => new SchemasClient(HttpClient, authorizations: Authorizations) + public SchemasClient Schemas => new SchemasClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -120,7 +123,7 @@ public sealed partial class MixedbreadClient : global::Mixedbread.IMixedbreadCli /// /// /// - public StoresClient Stores => new StoresClient(HttpClient, authorizations: Authorizations) + public StoresClient Stores => new StoresClient(HttpClient, authorizations: Authorizations, options: Options) { ReadResponseAsString = ReadResponseAsString, JsonSerializerContext = JsonSerializerContext, @@ -139,11 +142,37 @@ public MixedbreadClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the MixedbreadClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public MixedbreadClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.OptionsSupport.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.OptionsSupport.g.cs new file mode 100644 index 0000000..b79e897 --- /dev/null +++ b/src/libs/Mixedbread/Generated/Mixedbread.OptionsSupport.g.cs @@ -0,0 +1,460 @@ + +#nullable enable + +namespace Mixedbread +{ + /// + /// Global defaults applied to generated SDK requests. + /// + public sealed class AutoSDKClientOptions + { + /// + /// Additional headers applied to every request after generated headers are set. + /// Entries with the same key overwrite earlier header values. + /// + public global::System.Collections.Generic.Dictionary Headers { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase); + + /// + /// Additional query parameters appended to every request. + /// Request-level entries with the same key are appended after client defaults. + /// + public global::System.Collections.Generic.Dictionary QueryParameters { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal); + + /// + /// Optional timeout applied to the full request execution. + /// + public global::System.TimeSpan? Timeout { get; set; } + + /// + /// Default retry behavior for generated HTTP requests. + /// + public global::Mixedbread.AutoSDKRetryOptions Retry { get; set; } = new global::Mixedbread.AutoSDKRetryOptions(); + + /// + /// Overrides the client-wide response buffering mode when set. + /// + public bool? ReadResponseAsString { get; set; } + + /// + /// Reusable hooks invoked for every generated SDK request. + /// + public global::System.Collections.Generic.List Hooks { get; } = + new global::System.Collections.Generic.List(); + + /// + /// Registers a hook for all requests issued by this client. + /// + /// + /// The current options instance. + public global::Mixedbread.AutoSDKClientOptions AddHook( + global::Mixedbread.IAutoSDKHook hook) + { + Hooks.Add(hook ?? throw new global::System.ArgumentNullException(nameof(hook))); + return this; + } + } + + /// + /// Per-request overrides applied on top of . + /// + public sealed class AutoSDKRequestOptions + { + /// + /// Additional headers applied after generated and client-level headers. + /// + public global::System.Collections.Generic.Dictionary Headers { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.OrdinalIgnoreCase); + + /// + /// Additional query parameters appended after generated and client-level query parameters. + /// + public global::System.Collections.Generic.Dictionary QueryParameters { get; } = + new global::System.Collections.Generic.Dictionary(global::System.StringComparer.Ordinal); + + /// + /// Optional timeout override for this request. + /// + public global::System.TimeSpan? Timeout { get; set; } + + /// + /// Optional retry override for this request. + /// + public global::Mixedbread.AutoSDKRetryOptions? Retry { get; set; } + + /// + /// Overrides response buffering for this request when set. + /// + public bool? ReadResponseAsString { get; set; } + } + + /// + /// Retry settings for generated HTTP requests. + /// + public sealed class AutoSDKRetryOptions + { + /// + /// Total number of attempts, including the initial request. + /// Values less than 1 are normalized to 1. + /// + public int MaxAttempts { get; set; } = 1; + + /// + /// Optional fixed delay between retry attempts. + /// + public global::System.TimeSpan? Delay { get; set; } + } + + /// + /// Runtime hook interface for generated SDK lifecycle events. + /// + public interface IAutoSDKHook + { + /// + /// Runs before a request is sent. + /// + /// + global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Mixedbread.AutoSDKHookContext context); + + /// + /// Runs after a successful HTTP response is received. + /// + /// + global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Mixedbread.AutoSDKHookContext context); + + /// + /// Runs after an error response or transport failure is observed. + /// + /// + global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Mixedbread.AutoSDKHookContext context); + } + + /// + /// Convenience base type for request hooks with no-op defaults. + /// + public abstract class AutoSDKHook : global::Mixedbread.IAutoSDKHook + { + /// + public virtual global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Mixedbread.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Mixedbread.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + + /// + public virtual global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Mixedbread.AutoSDKHookContext context) + { + return global::System.Threading.Tasks.Task.CompletedTask; + } + } + + /// + /// Runtime metadata passed to generated SDK hooks. + /// + public sealed class AutoSDKHookContext + { + /// + /// The source OpenAPI operation id or generated fallback id. + /// + public string OperationId { get; set; } = string.Empty; + + /// + /// The generated C# method name. + /// + public string MethodName { get; set; } = string.Empty; + + /// + /// The OpenAPI path template for the operation. + /// + public string PathTemplate { get; set; } = string.Empty; + + /// + /// The HTTP method used for the request. + /// + public string HttpMethod { get; set; } = string.Empty; + + /// + /// The client's resolved base URI. + /// + public global::System.Uri? BaseUri { get; set; } + + /// + /// The outgoing HTTP request for the current attempt. + /// + public global::System.Net.Http.HttpRequestMessage Request { get; set; } = null!; + + /// + /// The HTTP response when one was received. + /// + public global::System.Net.Http.HttpResponseMessage? Response { get; set; } + + /// + /// The transport or processing exception when one was observed. + /// + public global::System.Exception? Exception { get; set; } + + /// + /// The client-wide runtime options. + /// + public global::Mixedbread.AutoSDKClientOptions ClientOptions { get; set; } = null!; + + /// + /// The per-request runtime options. + /// + public global::Mixedbread.AutoSDKRequestOptions? RequestOptions { get; set; } + + /// + /// The current attempt number, starting at 1. + /// + public int Attempt { get; set; } + + /// + /// The total number of attempts allowed for this request. + /// + public int MaxAttempts { get; set; } + + /// + /// Indicates whether the generated client will retry after this hook invocation. + /// + public bool WillRetry { get; set; } + + /// + /// The effective cancellation token for the current request attempt. + /// + public global::System.Threading.CancellationToken CancellationToken { get; set; } + } + + internal static class AutoSDKRequestOptionsSupport + { + internal static global::Mixedbread.AutoSDKHookContext CreateHookContext( + string operationId, + string methodName, + string pathTemplate, + string httpMethod, + global::System.Uri? baseUri, + global::System.Net.Http.HttpRequestMessage request, + global::System.Net.Http.HttpResponseMessage? response, + global::System.Exception? exception, + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKRequestOptions? requestOptions, + int attempt, + int maxAttempts, + bool willRetry, + global::System.Threading.CancellationToken cancellationToken) + { + return new global::Mixedbread.AutoSDKHookContext + { + OperationId = operationId ?? string.Empty, + MethodName = methodName ?? string.Empty, + PathTemplate = pathTemplate ?? string.Empty, + HttpMethod = httpMethod ?? string.Empty, + BaseUri = baseUri, + Request = request, + Response = response, + Exception = exception, + ClientOptions = clientOptions, + RequestOptions = requestOptions, + Attempt = attempt, + MaxAttempts = maxAttempts, + WillRetry = willRetry, + CancellationToken = cancellationToken, + }; + } + + internal static global::System.Threading.Tasks.Task OnBeforeRequestAsync( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnBeforeRequestAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterSuccessAsync( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterSuccessAsync(hookContext), context); + } + + internal static global::System.Threading.Tasks.Task OnAfterErrorAsync( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKHookContext context) + { + return InvokeHooksAsync(clientOptions, static (hook, hookContext) => hook.OnAfterErrorAsync(hookContext), context); + } + + internal static bool GetReadResponseAsString( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKRequestOptions? requestOptions, + bool fallbackValue) + { + return requestOptions?.ReadResponseAsString ?? + clientOptions.ReadResponseAsString ?? + fallbackValue; + } + + internal static global::System.Threading.CancellationTokenSource? CreateTimeoutCancellationTokenSource( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKRequestOptions? requestOptions, + global::System.Threading.CancellationToken cancellationToken) + { + var timeout = requestOptions?.Timeout ?? clientOptions.Timeout; + if (!timeout.HasValue || timeout.Value <= global::System.TimeSpan.Zero) + { + return null; + } + + var cancellationTokenSource = global::System.Threading.CancellationTokenSource.CreateLinkedTokenSource(cancellationToken); + cancellationTokenSource.CancelAfter(timeout.Value); + return cancellationTokenSource; + } + + internal static int GetMaxAttempts( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKRequestOptions? requestOptions, + bool supportsRetry) + { + if (!supportsRetry) + { + return 1; + } + + var maxAttempts = requestOptions?.Retry?.MaxAttempts ?? + clientOptions.Retry?.MaxAttempts ?? + 1; + return maxAttempts < 1 ? 1 : maxAttempts; + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::Mixedbread.AutoSDKRequestOptions? requestOptions, + global::System.Threading.CancellationToken cancellationToken) + { + var delay = requestOptions?.Retry?.Delay ?? + clientOptions.Retry?.Delay; + if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + { + return; + } + + await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + } + + internal static bool ShouldRetryStatusCode( + global::System.Net.HttpStatusCode statusCode) + { + return (int)statusCode switch + { + 408 => true, + 429 => true, + 500 => true, + 502 => true, + 503 => true, + 504 => true, + _ => false, + }; + } + + internal static string AppendQueryParameters( + string path, + global::System.Collections.Generic.Dictionary clientParameters, + global::System.Collections.Generic.Dictionary? requestParameters) + { + var hasClientParameters = clientParameters != null && clientParameters.Count > 0; + var hasRequestParameters = requestParameters != null && requestParameters.Count > 0; + if (!hasClientParameters && !hasRequestParameters) + { + return path; + } + + var builder = new global::System.Text.StringBuilder(path ?? string.Empty); + var hasQuery = builder.ToString().Contains("?", global::System.StringComparison.Ordinal); + AppendParameters(builder, clientParameters, ref hasQuery); + AppendParameters(builder, requestParameters, ref hasQuery); + return builder.ToString(); + } + + internal static void ApplyHeaders( + global::System.Net.Http.HttpRequestMessage request, + global::System.Collections.Generic.Dictionary clientHeaders, + global::System.Collections.Generic.Dictionary? requestHeaders) + { + ApplyHeadersCore(request, clientHeaders); + ApplyHeadersCore(request, requestHeaders); + } + + private static void AppendParameters( + global::System.Text.StringBuilder builder, + global::System.Collections.Generic.Dictionary? parameters, + ref bool hasQuery) + { + if (parameters == null || parameters.Count == 0) + { + return; + } + + foreach (var parameter in parameters) + { + builder.Append(hasQuery ? '&' : '?'); + builder.Append(global::System.Uri.EscapeDataString(parameter.Key)); + builder.Append('='); + builder.Append(global::System.Uri.EscapeDataString(parameter.Value ?? string.Empty)); + hasQuery = true; + } + } + + private static void ApplyHeadersCore( + global::System.Net.Http.HttpRequestMessage request, + global::System.Collections.Generic.Dictionary? headers) + { + if (headers == null || headers.Count == 0) + { + return; + } + + foreach (var header in headers) + { + request.Headers.Remove(header.Key); + request.Content?.Headers.Remove(header.Key); + + if (!request.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty) && + request.Content != null) + { + request.Content.Headers.TryAddWithoutValidation(header.Key, header.Value ?? string.Empty); + } + } + } + + private static async global::System.Threading.Tasks.Task InvokeHooksAsync( + global::Mixedbread.AutoSDKClientOptions clientOptions, + global::System.Func callback, + global::Mixedbread.AutoSDKHookContext context) + { + if (clientOptions.Hooks == null || clientOptions.Hooks.Count == 0) + { + return; + } + + foreach (var hook in clientOptions.Hooks) + { + if (hook == null) + { + continue; + } + + await callback(hook, context).ConfigureAwait(false); + } + } + } +} \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CancelParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CancelParsingJob.g.cs index 51bc35b..de6712a 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CancelParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CancelParsingJob.g.cs @@ -14,6 +14,7 @@ public partial class ParsingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessCancelParsingJobResponseContent( /// /// The ID of the parse job to cancel /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CancelParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessCancelParsingJobResponseContent( securityRequirements: s_CancelParsingJobSecurityRequirements, operationName: "CancelParsingJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/parsing/jobs/{jobId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/parsing/jobs/{jobId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessCancelParsingJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCancelParsingJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCancelParsingJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCancelParsingJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelParsingJob", + methodName: "CancelParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelParsingJob", + methodName: "CancelParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelParsingJob", + methodName: "CancelParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCancelParsingJobResponseContent( + response: __response); + ProcessCancelParsingJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelParsingJob", + methodName: "CancelParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CancelParsingJob", + methodName: "CancelParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCancelParsingJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CreateParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CreateParsingJob.g.cs index 4d53b21..5336560 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CreateParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.CreateParsingJob.g.cs @@ -14,6 +14,7 @@ public partial class ParsingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateParsingJobResponseContent( /// The created parsing job. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateParsingJobAsync( global::Mixedbread.ParsingJobCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateParsingJobResponseContent( securityRequirements: s_CreateParsingJobSecurityRequirements, operationName: "CreateParsingJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/parsing/jobs", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/parsing/jobs", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateParsingJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateParsingJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateParsingJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateParsingJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateParsingJob", + methodName: "CreateParsingJobAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateParsingJob", + methodName: "CreateParsingJobAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateParsingJob", + methodName: "CreateParsingJobAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateParsingJobResponseContent( + response: __response); + ProcessCreateParsingJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateParsingJob", + methodName: "CreateParsingJobAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateParsingJob", + methodName: "CreateParsingJobAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateParsingJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Start a parse job
@@ -272,6 +455,7 @@ partial void ProcessCreateParsingJobResponseContent( /// The strategy to use for OCR
/// Default Value: high_quality /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateParsingJobAsync( @@ -280,6 +464,7 @@ partial void ProcessCreateParsingJobResponseContent( global::Mixedbread.ChunkingStrategy? chunkingStrategy = default, global::Mixedbread.ReturnFormat? returnFormat = default, global::Mixedbread.Mode? mode = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.ParsingJobCreateParams @@ -293,6 +478,7 @@ partial void ProcessCreateParsingJobResponseContent( return await CreateParsingJobAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.DeleteParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.DeleteParsingJob.g.cs index b0c134e..6c9c722 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.DeleteParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.DeleteParsingJob.g.cs @@ -14,6 +14,7 @@ public partial class ParsingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDeleteParsingJobResponseContent( /// /// The ID of the parse job to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDeleteParsingJobResponseContent( securityRequirements: s_DeleteParsingJobSecurityRequirements, operationName: "DeleteParsingJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/parsing/jobs/{jobId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/parsing/jobs/{jobId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessDeleteParsingJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteParsingJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteParsingJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteParsingJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteParsingJob", + methodName: "DeleteParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteParsingJob", + methodName: "DeleteParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteParsingJob", + methodName: "DeleteParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteParsingJobResponseContent( + response: __response); + ProcessDeleteParsingJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ParsingJobDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteParsingJob", + methodName: "DeleteParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteParsingJob", + methodName: "DeleteParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ParsingJobDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteParsingJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ParsingJobDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ParsingJobDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.ListParsingJobs.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.ListParsingJobs.g.cs index a9c558a..9095489 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.ListParsingJobs.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.ListParsingJobs.g.cs @@ -14,6 +14,7 @@ public partial class ParsingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -79,6 +80,7 @@ partial void ProcessListParsingJobsResponseContent( /// /// Search query to filter by /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListParsingJobsAsync( @@ -88,6 +90,7 @@ partial void ProcessListParsingJobsResponseContent( bool? includeTotal = default, global::System.Collections.Generic.IList? statuses = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -107,30 +110,51 @@ partial void ProcessListParsingJobsResponseContent( securityRequirements: s_ListParsingJobsSecurityRequirements, operationName: "ListParsingJobsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/parsing/jobs", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("statuses", statuses?.ToString()) - .AddOptionalParameter("q", q) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/parsing/jobs", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("statuses", statuses?.ToString()) + .AddOptionalParameter("q", q) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -140,155 +164,314 @@ partial void ProcessListParsingJobsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListParsingJobsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal, - statuses: statuses, - q: q); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListParsingJobsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal, + statuses: statuses, + q: q); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListParsingJobsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListParsingJobs", + methodName: "ListParsingJobsAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListParsingJobs", + methodName: "ListParsingJobsAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListParsingJobs", + methodName: "ListParsingJobsAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListParsingJobsResponseContent( + response: __response); + ProcessListParsingJobsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ParsingJobListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListParsingJobs", + methodName: "ListParsingJobsAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListParsingJobs", + methodName: "ListParsingJobsAsync", + pathTemplate: "\"/v1/parsing/jobs\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ParsingJobListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListParsingJobsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ParsingJobListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ParsingJobListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.RetrieveParsingJob.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.RetrieveParsingJob.g.cs index bfa4ada..1912bed 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.RetrieveParsingJob.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.RetrieveParsingJob.g.cs @@ -14,6 +14,7 @@ public partial class ParsingClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveParsingJobResponseContent( /// /// The ID of the parse job to retrieve /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveParsingJobAsync( global::System.Guid jobId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveParsingJobResponseContent( securityRequirements: s_RetrieveParsingJobSecurityRequirements, operationName: "RetrieveParsingJobAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/parsing/jobs/{jobId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/parsing/jobs/{jobId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRetrieveParsingJobResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveParsingJobRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - jobId: jobId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveParsingJobRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + jobId: jobId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveParsingJobResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveParsingJob", + methodName: "RetrieveParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveParsingJob", + methodName: "RetrieveParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveParsingJob", + methodName: "RetrieveParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveParsingJobResponseContent( + response: __response); + ProcessRetrieveParsingJobResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveParsingJob", + methodName: "RetrieveParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveParsingJob", + methodName: "RetrieveParsingJobAsync", + pathTemplate: "$\"/v1/parsing/jobs/{jobId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveParsingJobResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.ParsingJob.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.ParsingJob.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.g.cs index 9afc859..87e393b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.ParsingClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class ParsingClient : global::Mixedbread.IParsingClient, g #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public ParsingClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the ParsingClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public ParsingClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.PathBuilder.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.PathBuilder.g.cs index 2ca2caf..ce8c2bd 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.PathBuilder.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.PathBuilder.g.cs @@ -275,6 +275,11 @@ public class EndPointAuthorization ///
public string Type { get; set; } = string.Empty; + /// + /// + /// + public string SchemeId { get; set; } = string.Empty; + /// /// /// diff --git a/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.GetMxbaiJsonSchema.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.GetMxbaiJsonSchema.g.cs index ecf08d5..820f0d9 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.GetMxbaiJsonSchema.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.GetMxbaiJsonSchema.g.cs @@ -14,6 +14,7 @@ public partial class SchemasClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,9 +45,11 @@ partial void ProcessGetMxbaiJsonSchemaResponseContent( /// Returns:
/// The mxbai json schema. ///
+ /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetMxbaiJsonSchemaAsync( + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -60,22 +63,43 @@ partial void ProcessGetMxbaiJsonSchemaResponseContent( securityRequirements: s_GetMxbaiJsonSchemaSecurityRequirements, operationName: "GetMxbaiJsonSchemaAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/schemas/mxjson", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/schemas/mxjson", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -85,107 +109,266 @@ partial void ProcessGetMxbaiJsonSchemaResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetMxbaiJsonSchemaRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest); - - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetMxbaiJsonSchemaRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetMxbaiJsonSchemaResponse( - httpClient: HttpClient, - httpResponseMessage: __response); + return __httpRequest; + } - if (ReadResponseAsString) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMxbaiJsonSchema", + methodName: "GetMxbaiJsonSchemaAsync", + pathTemplate: "\"/v1/schemas/mxjson\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMxbaiJsonSchema", + methodName: "GetMxbaiJsonSchemaAsync", + pathTemplate: "\"/v1/schemas/mxjson\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - ProcessResponseContent( - client: HttpClient, - response: __response, - content: ref __content); - ProcessGetMxbaiJsonSchemaResponseContent( - httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - try - { - __response.EnsureSuccessStatusCode(); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMxbaiJsonSchema", + methodName: "GetMxbaiJsonSchemaAsync", + pathTemplate: "\"/v1/schemas/mxjson\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - return __content; + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + throw new global::System.InvalidOperationException("No response received."); } - } - else - { - try + + using (__response) { - __response.EnsureSuccessStatusCode(); - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - return __content; + ProcessResponse( + client: HttpClient, + response: __response); + ProcessGetMxbaiJsonSchemaResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMxbaiJsonSchema", + methodName: "GetMxbaiJsonSchemaAsync", + pathTemplate: "\"/v1/schemas/mxjson\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMxbaiJsonSchema", + methodName: "GetMxbaiJsonSchemaAsync", + pathTemplate: "\"/v1/schemas/mxjson\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetMxbaiJsonSchemaResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return __content; + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return __content; + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.g.cs index 9234b56..1e341a2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.SchemasClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class SchemasClient : global::Mixedbread.ISchemasClient, g #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public SchemasClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the SchemasClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public SchemasClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient); diff --git a/src/libs/Mixedbread/Generated/Mixedbread.Security.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.Security.g.cs index 01803e6..6eb04bc 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.Security.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.Security.g.cs @@ -6,6 +6,8 @@ internal sealed class EndPointAuthorizationRequirement { internal string Type { get; set; } = string.Empty; + internal string SchemeId { get; set; } = string.Empty; + internal string Location { get; set; } = string.Empty; internal string Name { get; set; } = string.Empty; @@ -97,7 +99,18 @@ private static bool Matches( return requiredAuthorization.Type switch { - "OAuth2" => true, + "OAuth2" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), + "OpenIdConnect" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), + "MutualTLS" => string.Equals( + availableAuthorization.SchemeId, + requiredAuthorization.SchemeId, + global::System.StringComparison.Ordinal), "Http" => string.Equals( availableAuthorization.Name, requiredAuthorization.Name, diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateQuestionAnswering.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateQuestionAnswering.g.cs index 5127f2c..4505046 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateQuestionAnswering.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateQuestionAnswering.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,11 +45,13 @@ partial void ProcessCreateQuestionAnsweringResponseContent( /// Question answering ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateQuestionAnsweringAsync( global::Mixedbread.StoreQAParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -65,22 +68,43 @@ partial void ProcessCreateQuestionAnsweringResponseContent( securityRequirements: s_CreateQuestionAnsweringSecurityRequirements, operationName: "CreateQuestionAnsweringAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores/question-answering", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores/question-answering", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,156 +114,315 @@ partial void ProcessCreateQuestionAnsweringResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateQuestionAnsweringRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateQuestionAnsweringRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateQuestionAnsweringResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateQuestionAnswering", + methodName: "CreateQuestionAnsweringAsync", + pathTemplate: "\"/v1/stores/question-answering\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateQuestionAnswering", + methodName: "CreateQuestionAnsweringAsync", + pathTemplate: "\"/v1/stores/question-answering\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateQuestionAnswering", + methodName: "CreateQuestionAnsweringAsync", + pathTemplate: "\"/v1/stores/question-answering\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateQuestionAnsweringResponseContent( + response: __response); + ProcessCreateQuestionAnsweringResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreQAResults.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateQuestionAnswering", + methodName: "CreateQuestionAnsweringAsync", + pathTemplate: "\"/v1/stores/question-answering\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateQuestionAnswering", + methodName: "CreateQuestionAnsweringAsync", + pathTemplate: "\"/v1/stores/question-answering\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreQAResults.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateQuestionAnsweringResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreQAResults.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreQAResults.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Question answering @@ -273,6 +456,7 @@ partial void ProcessCreateQuestionAnsweringResponseContent( /// /// Question answering configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateQuestionAnsweringAsync( @@ -285,6 +469,7 @@ partial void ProcessCreateQuestionAnsweringResponseContent( bool? stream = default, string? instructions = default, global::Mixedbread.QuestionAnsweringOptions? qaOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreQAParams @@ -302,6 +487,7 @@ partial void ProcessCreateQuestionAnsweringResponseContent( return await CreateQuestionAnsweringAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateSearchRule.g.cs index fced647..139e068 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateSearchRule.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessCreateSearchRuleResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessCreateSearchRuleResponseContent( securityRequirements: s_CreateSearchRuleSecurityRequirements, operationName: "CreateSearchRuleAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/rules", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/rules", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessCreateSearchRuleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateSearchRuleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateSearchRuleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateSearchRuleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSearchRule", + methodName: "CreateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSearchRule", + methodName: "CreateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSearchRule", + methodName: "CreateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateSearchRuleResponseContent( + response: __response); + ProcessCreateSearchRuleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSearchRule", + methodName: "CreateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateSearchRule", + methodName: "CreateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateSearchRuleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create search rule
@@ -273,12 +456,14 @@ partial void ProcessCreateSearchRuleResponseContent( /// /// The rules to apply on query matches /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, string query, global::System.Collections.Generic.IList rules, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleCreateParams @@ -290,6 +475,7 @@ partial void ProcessCreateSearchRuleResponseContent( return await CreateSearchRuleAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStore.g.cs index f4b5fdf..43fe5c3 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStore.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -49,11 +50,13 @@ partial void ProcessCreateStoreResponseContent( /// VectorStore: The response containing the created vector store details. ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateStoreAsync( global::Mixedbread.StoreCreateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -70,22 +73,43 @@ partial void ProcessCreateStoreResponseContent( securityRequirements: s_CreateStoreSecurityRequirements, operationName: "CreateStoreAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -95,156 +119,315 @@ partial void ProcessCreateStoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateStoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateStoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateStoreResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStore", + methodName: "CreateStoreAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStore", + methodName: "CreateStoreAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStore", + methodName: "CreateStoreAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateStoreResponseContent( + response: __response); + ProcessCreateStoreResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStore", + methodName: "CreateStoreAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStore", + methodName: "CreateStoreAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateStoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Create a store
@@ -276,6 +459,7 @@ partial void ProcessCreateStoreResponseContent( /// /// Optional list of file IDs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateStoreAsync( @@ -286,6 +470,7 @@ partial void ProcessCreateStoreResponseContent( object? metadata = default, global::Mixedbread.StoreConfig2? config = default, global::System.Collections.Generic.IList? fileIds = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreCreateParams @@ -301,6 +486,7 @@ partial void ProcessCreateStoreResponseContent( return await CreateStoreAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStoreFile.g.cs index 1b36746..e5d1cf3 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.CreateStoreFile.g.cs @@ -16,6 +16,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessCreateStoreFileResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.DeprecatedStoreFileUpsertParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -80,22 +83,43 @@ partial void ProcessCreateStoreFileResponseContent( securityRequirements: s_CreateStoreFileSecurityRequirements, operationName: "CreateStoreFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -105,157 +129,316 @@ partial void ProcessCreateStoreFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareCreateStoreFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreateStoreFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessCreateStoreFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStoreFile", + methodName: "CreateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStoreFile", + methodName: "CreateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStoreFile", + methodName: "CreateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessCreateStoreFileResponseContent( + response: __response); + ProcessCreateStoreFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStoreFile", + methodName: "CreateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "CreateStoreFile", + methodName: "CreateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreateStoreFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Upload file to store
@@ -285,6 +468,7 @@ partial void ProcessCreateStoreFileResponseContent( /// /// ID of the file to add /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task CreateStoreFileAsync( @@ -294,6 +478,7 @@ partial void ProcessCreateStoreFileResponseContent( global::Mixedbread.StoreFileConfig2? config = default, string? externalId = default, bool? overwrite = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.DeprecatedStoreFileUpsertParams @@ -308,6 +493,7 @@ partial void ProcessCreateStoreFileResponseContent( return await CreateStoreFileAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSearchRule.g.cs index 66394e9..05f511b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSearchRule.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessDeleteSearchRuleResponseContent( /// /// The ID of the search rule to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessDeleteSearchRuleResponseContent( securityRequirements: s_DeleteSearchRuleSecurityRequirements, operationName: "DeleteSearchRuleAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,151 +126,310 @@ partial void ProcessDeleteSearchRuleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteSearchRuleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - ruleId: ruleId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteSearchRuleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + ruleId: ruleId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteSearchRuleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSearchRule", + methodName: "DeleteSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSearchRule", + methodName: "DeleteSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSearchRule", + methodName: "DeleteSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteSearchRuleResponseContent( + response: __response); + ProcessDeleteSearchRuleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSearchRule", + methodName: "DeleteSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSearchRule", + methodName: "DeleteSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteSearchRuleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSpecificSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSpecificSearchRule.g.cs index 0ba0621..fff5acb 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSpecificSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteSpecificSearchRule.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,6 +62,7 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( /// The ID of the search rule /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteSpecificSearchRuleAsync( @@ -68,6 +70,7 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( global::System.Guid ruleId, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleteParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -86,22 +89,43 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( securityRequirements: s_DeleteSpecificSearchRuleSecurityRequirements, operationName: "DeleteSpecificSearchRuleAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,158 +135,317 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteSpecificSearchRuleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - ruleId: ruleId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteSpecificSearchRuleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + ruleId: ruleId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteSpecificSearchRuleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSpecificSearchRule", + methodName: "DeleteSpecificSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSpecificSearchRule", + methodName: "DeleteSpecificSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSpecificSearchRule", + methodName: "DeleteSpecificSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteSpecificSearchRuleResponseContent( + response: __response); + ProcessDeleteSpecificSearchRuleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSpecificSearchRule", + methodName: "DeleteSpecificSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteSpecificSearchRule", + methodName: "DeleteSpecificSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}/specific\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteSpecificSearchRuleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Delete a specific rule from rules array
@@ -283,12 +466,14 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( /// /// The specific rule to delete from the rules array /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteSpecificSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, global::Mixedbread.Rule2 rule, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleSpecificDeleteParams @@ -300,6 +485,7 @@ partial void ProcessDeleteSpecificSearchRuleResponseContent( storeIdentifier: storeIdentifier, ruleId: ruleId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStore.g.cs index 13293d8..8ff0a8b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStore.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessDeleteStoreResponseContent( /// /// The ID or name of the store to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteStoreAsync( global::Mixedbread.AnyOf storeIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessDeleteStoreResponseContent( securityRequirements: s_DeleteStoreSecurityRequirements, operationName: "DeleteStoreAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessDeleteStoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteStoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteStoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteStoreResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStore", + methodName: "DeleteStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStore", + methodName: "DeleteStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStore", + methodName: "DeleteStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteStoreResponseContent( + response: __response); + ProcessDeleteStoreResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStore", + methodName: "DeleteStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStore", + methodName: "DeleteStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteStoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStoreFile.g.cs index 65b389d..d1f3f16 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.DeleteStoreFile.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessDeleteStoreFileResponseContent( /// /// The ID or name of the file to delete /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task DeleteStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessDeleteStoreFileResponseContent( securityRequirements: s_DeleteStoreFileSecurityRequirements, operationName: "DeleteStoreFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Delete, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Delete, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,151 +126,310 @@ partial void ProcessDeleteStoreFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareDeleteStoreFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - fileIdentifier: fileIdentifier); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareDeleteStoreFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + fileIdentifier: fileIdentifier); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessDeleteStoreFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStoreFile", + methodName: "DeleteStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStoreFile", + methodName: "DeleteStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStoreFile", + methodName: "DeleteStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessDeleteStoreFileResponseContent( + response: __response); + ProcessDeleteStoreFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFileDeleted.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStoreFile", + methodName: "DeleteStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "DeleteStoreFile", + methodName: "DeleteStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "DELETE", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessDeleteStoreFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFileDeleted.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFileDeleted.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetMetadataFacets.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetMetadataFacets.g.cs index b05d070..2e0447b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetMetadataFacets.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetMetadataFacets.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -44,11 +45,13 @@ partial void ProcessGetMetadataFacetsResponseContent( /// Get metadata facets ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetMetadataFacetsAsync( global::Mixedbread.MetadataFacetsParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -65,22 +68,43 @@ partial void ProcessGetMetadataFacetsResponseContent( securityRequirements: s_GetMetadataFacetsSecurityRequirements, operationName: "GetMetadataFacetsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores/metadata-facets", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores/metadata-facets", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -90,156 +114,315 @@ partial void ProcessGetMetadataFacetsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetMetadataFacetsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetMetadataFacetsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetMetadataFacetsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMetadataFacets", + methodName: "GetMetadataFacetsAsync", + pathTemplate: "\"/v1/stores/metadata-facets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMetadataFacets", + methodName: "GetMetadataFacetsAsync", + pathTemplate: "\"/v1/stores/metadata-facets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMetadataFacets", + methodName: "GetMetadataFacetsAsync", + pathTemplate: "\"/v1/stores/metadata-facets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetMetadataFacetsResponseContent( + response: __response); + ProcessGetMetadataFacetsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MetadataFacets.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMetadataFacets", + methodName: "GetMetadataFacetsAsync", + pathTemplate: "\"/v1/stores/metadata-facets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetMetadataFacets", + methodName: "GetMetadataFacetsAsync", + pathTemplate: "\"/v1/stores/metadata-facets\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MetadataFacets.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetMetadataFacetsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MetadataFacets.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MetadataFacets.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Get metadata facets @@ -266,6 +449,7 @@ partial void ProcessGetMetadataFacetsResponseContent( /// /// Optional list of facets to return. Use dot for nested fields. /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetMetadataFacetsAsync( @@ -276,6 +460,7 @@ partial void ProcessGetMetadataFacetsResponseContent( global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreChunkSearchOptions? searchOptions = default, global::System.Collections.Generic.IList? facets = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.MetadataFacetsParams @@ -291,6 +476,7 @@ partial void ProcessGetMetadataFacetsResponseContent( return await GetMetadataFacetsAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetStoreEventHistogram.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetStoreEventHistogram.g.cs index d7ba8ed..1f9760e 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetStoreEventHistogram.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.GetStoreEventHistogram.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessGetStoreEventHistogramResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetStoreEventHistogramAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.StoreEventHistogramParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessGetStoreEventHistogramResponseContent( securityRequirements: s_GetStoreEventHistogramSecurityRequirements, operationName: "GetStoreEventHistogramAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/events/histogram", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/events/histogram", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessGetStoreEventHistogramResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareGetStoreEventHistogramRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareGetStoreEventHistogramRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessGetStoreEventHistogramResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreEventHistogram", + methodName: "GetStoreEventHistogramAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events/histogram\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreEventHistogram", + methodName: "GetStoreEventHistogramAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events/histogram\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreEventHistogram", + methodName: "GetStoreEventHistogramAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events/histogram\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessGetStoreEventHistogramResponseContent( + response: __response); + ProcessGetStoreEventHistogramResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreEventHistogramResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreEventHistogram", + methodName: "GetStoreEventHistogramAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events/histogram\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "GetStoreEventHistogram", + methodName: "GetStoreEventHistogramAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events/histogram\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreEventHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessGetStoreEventHistogramResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreEventHistogramResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreEventHistogramResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Get store event histogram
@@ -277,6 +460,7 @@ partial void ProcessGetStoreEventHistogramResponseContent( /// Number of seconds in each bucket
/// Default Value: 7200 /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task GetStoreEventHistogramAsync( @@ -284,6 +468,7 @@ partial void ProcessGetStoreEventHistogramResponseContent( global::System.DateTime? startTime = default, global::System.DateTime? endTime = default, int? bucketSeconds = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreEventHistogramParams @@ -296,6 +481,7 @@ partial void ProcessGetStoreEventHistogramResponseContent( return await GetStoreEventHistogramAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreEvents.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreEvents.g.cs index 62f592b..061c2a3 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreEvents.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreEvents.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -89,6 +90,7 @@ partial void ProcessListStoreEventsResponseContent( /// /// The type of event to list /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListStoreEventsAsync( @@ -100,6 +102,7 @@ partial void ProcessListStoreEventsResponseContent( bool? includeTotal = default, global::System.DateTime? filterBefore = default, global::System.DateTime? filterAfter = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -121,31 +124,52 @@ partial void ProcessListStoreEventsResponseContent( securityRequirements: s_ListStoreEventsSecurityRequirements, operationName: "ListStoreEventsAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/events", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("filter_before", filterBefore?.ToString()) - .AddOptionalParameter("filter_after", filterAfter?.ToString()) - .AddRequiredParameter("event_type", eventType.ToValueString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/events", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("filter_before", filterBefore?.ToString()) + .AddOptionalParameter("filter_after", filterAfter?.ToString()) + .AddRequiredParameter("event_type", eventType.ToValueString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -155,157 +179,316 @@ partial void ProcessListStoreEventsResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListStoreEventsRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal, - filterBefore: filterBefore, - filterAfter: filterAfter, - eventType: eventType); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListStoreEventsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal, + filterBefore: filterBefore, + filterAfter: filterAfter, + eventType: eventType); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListStoreEventsResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreEvents", + methodName: "ListStoreEventsAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreEvents", + methodName: "ListStoreEventsAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreEvents", + methodName: "ListStoreEventsAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListStoreEventsResponseContent( + response: __response); + ProcessListStoreEventsResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreEventListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreEvents", + methodName: "ListStoreEventsAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreEvents", + methodName: "ListStoreEventsAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/events\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreEventListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListStoreEventsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreEventListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreEventListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreFilesWithMetadataFilter.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreFilesWithMetadataFilter.g.cs index d155583..d260a15 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreFilesWithMetadataFilter.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStoreFilesWithMetadataFilter.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListStoreFilesWithMetadataFilterAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.SearchCursorPagination request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( securityRequirements: s_ListStoreFilesWithMetadataFilterSecurityRequirements, operationName: "ListStoreFilesWithMetadataFilterAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files/list", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files/list", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListStoreFilesWithMetadataFilterRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListStoreFilesWithMetadataFilterRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListStoreFilesWithMetadataFilterResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreFilesWithMetadataFilter", + methodName: "ListStoreFilesWithMetadataFilterAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/list\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreFilesWithMetadataFilter", + methodName: "ListStoreFilesWithMetadataFilterAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/list\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreFilesWithMetadataFilter", + methodName: "ListStoreFilesWithMetadataFilterAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/list\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListStoreFilesWithMetadataFilterResponseContent( + response: __response); + ProcessListStoreFilesWithMetadataFilterResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFileListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreFilesWithMetadataFilter", + methodName: "ListStoreFilesWithMetadataFilterAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/list\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStoreFilesWithMetadataFilter", + methodName: "ListStoreFilesWithMetadataFilterAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/list\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFileListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListStoreFilesWithMetadataFilterResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFileListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFileListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// List store files with metadata filter
@@ -290,6 +473,7 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( /// /// Search query for fuzzy matching over name and external_id fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListStoreFilesWithMetadataFilterAsync( @@ -301,6 +485,7 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( global::System.Collections.Generic.IList? statuses = default, global::Mixedbread.AnyOf>, object>? metadataFilter = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.SearchCursorPagination @@ -317,6 +502,7 @@ partial void ProcessListStoreFilesWithMetadataFilterResponseContent( return await ListStoreFilesWithMetadataFilterAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStores.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStores.g.cs index f30ac58..53bcdff 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStores.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.ListStores.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -74,6 +75,7 @@ partial void ProcessListStoresResponseContent( /// /// Search query for fuzzy matching over name and description fields /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task ListStoresAsync( @@ -82,6 +84,7 @@ partial void ProcessListStoresResponseContent( string? before = default, bool? includeTotal = default, string? q = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -100,29 +103,50 @@ partial void ProcessListStoresResponseContent( securityRequirements: s_ListStoresSecurityRequirements, operationName: "ListStoresAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("limit", limit?.ToString()) - .AddOptionalParameter("after", after) - .AddOptionalParameter("before", before) - .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) - .AddOptionalParameter("q", q) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("limit", limit?.ToString()) + .AddOptionalParameter("after", after) + .AddOptionalParameter("before", before) + .AddOptionalParameter("include_total", includeTotal?.ToString().ToLowerInvariant()) + .AddOptionalParameter("q", q) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -132,154 +156,313 @@ partial void ProcessListStoresResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareListStoresRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - limit: limit, - after: after, - before: before, - includeTotal: includeTotal, - q: q); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareListStoresRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + limit: limit, + after: after, + before: before, + includeTotal: includeTotal, + q: q); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessListStoresResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStores", + methodName: "ListStoresAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStores", + methodName: "ListStoresAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStores", + methodName: "ListStoresAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessListStoresResponseContent( + response: __response); + ProcessListStoresResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreListResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStores", + methodName: "ListStoresAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "ListStores", + methodName: "ListStoresAsync", + pathTemplate: "\"/v1/stores\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessListStoresResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreListResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreListResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveSearchRule.g.cs index 003c4d6..9b571f7 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveSearchRule.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,11 +58,13 @@ partial void ProcessRetrieveSearchRuleResponseContent( /// /// The ID of the search rule /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveSearchRuleAsync( global::Mixedbread.AnyOf storeIdentifier, global::System.Guid ruleId, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -77,22 +80,43 @@ partial void ProcessRetrieveSearchRuleResponseContent( securityRequirements: s_RetrieveSearchRuleSecurityRequirements, operationName: "RetrieveSearchRuleAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -102,151 +126,310 @@ partial void ProcessRetrieveSearchRuleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveSearchRuleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - ruleId: ruleId); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveSearchRuleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + ruleId: ruleId); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveSearchRuleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveSearchRule", + methodName: "RetrieveSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveSearchRule", + methodName: "RetrieveSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveSearchRule", + methodName: "RetrieveSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveSearchRuleResponseContent( + response: __response); + ProcessRetrieveSearchRuleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveSearchRule", + methodName: "RetrieveSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveSearchRule", + methodName: "RetrieveSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveSearchRuleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStore.g.cs index f4f732b..307555c 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStore.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -51,10 +52,12 @@ partial void ProcessRetrieveStoreResponseContent( /// /// The ID or name of the store /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveStoreAsync( global::Mixedbread.AnyOf storeIdentifier, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -69,22 +72,43 @@ partial void ProcessRetrieveStoreResponseContent( securityRequirements: s_RetrieveStoreSecurityRequirements, operationName: "RetrieveStoreAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -94,150 +118,309 @@ partial void ProcessRetrieveStoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveStoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveStoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveStoreResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStore", + methodName: "RetrieveStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStore", + methodName: "RetrieveStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStore", + methodName: "RetrieveStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveStoreResponseContent( + response: __response); + ProcessRetrieveStoreResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStore", + methodName: "RetrieveStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStore", + methodName: "RetrieveStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveStoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStoreFile.g.cs index d6f773b..6b79b93 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.RetrieveStoreFile.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -64,12 +65,14 @@ partial void ProcessRetrieveStoreFileResponseContent( /// Whether to return the chunks for the file. If a list of integers is provided, only the chunks at the specified indices will be returned.
/// Default Value: false /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task RetrieveStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, global::Mixedbread.AnyOf>? returnChunks = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( @@ -86,25 +89,46 @@ partial void ProcessRetrieveStoreFileResponseContent( securityRequirements: s_RetrieveStoreFileSecurityRequirements, operationName: "RetrieveStoreFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", - baseUri: HttpClient.BaseAddress); - __pathBuilder - .AddOptionalParameter("return_chunks", returnChunks?.ToString()) - ; - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Get, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", + baseUri: HttpClient.BaseAddress); + __pathBuilder + .AddOptionalParameter("return_chunks", returnChunks?.ToString()) + ; + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Get, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -114,152 +138,311 @@ partial void ProcessRetrieveStoreFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareRetrieveStoreFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - fileIdentifier: fileIdentifier, - returnChunks: returnChunks); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareRetrieveStoreFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + fileIdentifier: fileIdentifier, + returnChunks: returnChunks); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessRetrieveStoreFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStoreFile", + methodName: "RetrieveStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStoreFile", + methodName: "RetrieveStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStoreFile", + methodName: "RetrieveStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessRetrieveStoreFileResponseContent( + response: __response); + ProcessRetrieveStoreFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStoreFile", + methodName: "RetrieveStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "RetrieveStoreFile", + methodName: "RetrieveStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "GET", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessRetrieveStoreFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } } } \ No newline at end of file diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreChunks.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreChunks.g.cs index 26289cb..bd9f8b5 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreChunks.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreChunks.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -67,11 +68,13 @@ partial void ProcessSearchStoreChunksResponseContent( /// HTTPException (404): If no vector stores are found to search ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task SearchStoreChunksAsync( global::Mixedbread.StoreChunkSearchParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -88,22 +91,43 @@ partial void ProcessSearchStoreChunksResponseContent( securityRequirements: s_SearchStoreChunksSecurityRequirements, operationName: "SearchStoreChunksAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores/search", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores/search", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -113,156 +137,315 @@ partial void ProcessSearchStoreChunksResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSearchStoreChunksRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSearchStoreChunksRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSearchStoreChunksResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreChunks", + methodName: "SearchStoreChunksAsync", + pathTemplate: "\"/v1/stores/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreChunks", + methodName: "SearchStoreChunksAsync", + pathTemplate: "\"/v1/stores/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreChunks", + methodName: "SearchStoreChunksAsync", + pathTemplate: "\"/v1/stores/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessSearchStoreChunksResponseContent( + response: __response); + ProcessSearchStoreChunksResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreSearchResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreChunks", + methodName: "SearchStoreChunksAsync", + pathTemplate: "\"/v1/stores/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreChunks", + methodName: "SearchStoreChunksAsync", + pathTemplate: "\"/v1/stores/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessSearchStoreChunksResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreSearchResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Perform semantic search across store chunks
@@ -309,6 +492,7 @@ partial void ProcessSearchStoreChunksResponseContent( /// /// Search configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task SearchStoreChunksAsync( @@ -318,6 +502,7 @@ partial void ProcessSearchStoreChunksResponseContent( global::Mixedbread.AnyOf>, object>? filters = default, global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreChunkSearchOptions? searchOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreChunkSearchParams @@ -332,6 +517,7 @@ partial void ProcessSearchStoreChunksResponseContent( return await SearchStoreChunksAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreFiles.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreFiles.g.cs index d02ec6e..e7f66a5 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreFiles.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.SearchStoreFiles.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -50,11 +51,13 @@ partial void ProcessSearchStoreFilesResponseContent( /// StoreFileSearchResponse: List of matching files with relevance scores ///
/// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task SearchStoreFilesAsync( global::Mixedbread.StoreFileSearchParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -71,22 +74,43 @@ partial void ProcessSearchStoreFilesResponseContent( securityRequirements: s_SearchStoreFilesSecurityRequirements, operationName: "SearchStoreFilesAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: "/v1/stores/files/search", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: "/v1/stores/files/search", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -96,156 +120,315 @@ partial void ProcessSearchStoreFilesResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareSearchStoreFilesRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareSearchStoreFilesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessSearchStoreFilesResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreFiles", + methodName: "SearchStoreFilesAsync", + pathTemplate: "\"/v1/stores/files/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreFiles", + methodName: "SearchStoreFilesAsync", + pathTemplate: "\"/v1/stores/files/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreFiles", + methodName: "SearchStoreFilesAsync", + pathTemplate: "\"/v1/stores/files/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessSearchStoreFilesResponseContent( + response: __response); + ProcessSearchStoreFilesResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFileSearchResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreFiles", + methodName: "SearchStoreFilesAsync", + pathTemplate: "\"/v1/stores/files/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "SearchStoreFiles", + methodName: "SearchStoreFilesAsync", + pathTemplate: "\"/v1/stores/files/search\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFileSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessSearchStoreFilesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFileSearchResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFileSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Search store files
@@ -275,6 +458,7 @@ partial void ProcessSearchStoreFilesResponseContent( /// /// Search configuration options /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task SearchStoreFilesAsync( @@ -284,6 +468,7 @@ partial void ProcessSearchStoreFilesResponseContent( global::Mixedbread.AnyOf>, object>? filters = default, global::Mixedbread.AnyOf>>, global::System.Collections.Generic.IList, object>? fileIds = default, global::Mixedbread.StoreFileSearchOptions? searchOptions = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreFileSearchParams @@ -298,6 +483,7 @@ partial void ProcessSearchStoreFilesResponseContent( return await SearchStoreFilesAsync( request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateSearchRule.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateSearchRule.g.cs index 375318a..09670b2 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateSearchRule.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateSearchRule.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,6 +62,7 @@ partial void ProcessUpdateSearchRuleResponseContent( /// The ID of the search rule to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateSearchRuleAsync( @@ -68,6 +70,7 @@ partial void ProcessUpdateSearchRuleResponseContent( global::System.Guid ruleId, global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -86,22 +89,43 @@ partial void ProcessUpdateSearchRuleResponseContent( securityRequirements: s_UpdateSearchRuleSecurityRequirements, operationName: "UpdateSearchRuleAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/rules/{ruleId}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,158 +135,317 @@ partial void ProcessUpdateSearchRuleResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateSearchRuleRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - ruleId: ruleId, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateSearchRuleRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + ruleId: ruleId, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateSearchRuleResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSearchRule", + methodName: "UpdateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSearchRule", + methodName: "UpdateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSearchRule", + methodName: "UpdateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateSearchRuleResponseContent( + response: __response); + ProcessUpdateSearchRuleResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSearchRule", + methodName: "UpdateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateSearchRule", + methodName: "UpdateSearchRuleAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/rules/{ruleId}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateSearchRuleResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update a search rule
@@ -286,6 +469,7 @@ partial void ProcessUpdateSearchRuleResponseContent( /// /// The rules to apply on query matches /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateSearchRuleAsync( @@ -293,6 +477,7 @@ partial void ProcessUpdateSearchRuleResponseContent( global::System.Guid ruleId, string? query = default, global::System.Collections.Generic.IList? rules = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.MxbaiOmniApiRoutesV1StoresRulesModelsSearchRuleUpdateParams @@ -305,6 +490,7 @@ partial void ProcessUpdateSearchRuleResponseContent( storeIdentifier: storeIdentifier, ruleId: ruleId, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStore.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStore.g.cs index 3b9b6ab..d80449b 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStore.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStore.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -55,12 +56,14 @@ partial void ProcessUpdateStoreResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateStoreAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.StoreUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -78,22 +81,43 @@ partial void ProcessUpdateStoreResponseContent( securityRequirements: s_UpdateStoreSecurityRequirements, operationName: "UpdateStoreAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Put, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Put, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -103,157 +127,316 @@ partial void ProcessUpdateStoreResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateStoreRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateStoreRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateStoreResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStore", + methodName: "UpdateStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStore", + methodName: "UpdateStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStore", + methodName: "UpdateStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateStoreResponseContent( + response: __response); + ProcessUpdateStoreResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStore", + methodName: "UpdateStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStore", + methodName: "UpdateStoreAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}\"", + httpMethod: "PUT", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateStoreResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.Store.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.Store.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update a store
@@ -282,6 +465,7 @@ partial void ProcessUpdateStoreResponseContent( /// /// Optional metadata key-value pairs /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateStoreAsync( @@ -291,6 +475,7 @@ partial void ProcessUpdateStoreResponseContent( bool? isPublic = default, global::Mixedbread.ExpiresAfter? expiresAfter = default, object? metadata = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreUpdateParams @@ -305,6 +490,7 @@ partial void ProcessUpdateStoreResponseContent( return await UpdateStoreAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStoreFile.g.cs index 06e0c7a..c2ce560 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UpdateStoreFile.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -61,6 +62,7 @@ partial void ProcessUpdateStoreFileResponseContent( /// The ID or name of the file to update /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateStoreFileAsync( @@ -68,6 +70,7 @@ partial void ProcessUpdateStoreFileResponseContent( global::Mixedbread.AnyOf fileIdentifier, global::Mixedbread.StoreFileMetadataUpdateParams request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -86,22 +89,43 @@ partial void ProcessUpdateStoreFileResponseContent( securityRequirements: s_UpdateStoreFileSecurityRequirements, operationName: "UpdateStoreFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: new global::System.Net.Http.HttpMethod("PATCH"), - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files/{fileIdentifier}", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: new global::System.Net.Http.HttpMethod("PATCH"), + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -111,158 +135,317 @@ partial void ProcessUpdateStoreFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - var __httpRequestContentBody = request.ToJson(JsonSerializerContext); - var __httpRequestContent = new global::System.Net.Http.StringContent( - content: __httpRequestContentBody, - encoding: global::System.Text.Encoding.UTF8, - mediaType: "application/json"); - __httpRequest.Content = __httpRequestContent; - - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUpdateStoreFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - fileIdentifier: fileIdentifier, - request: request); + var __httpRequestContentBody = request.ToJson(JsonSerializerContext); + var __httpRequestContent = new global::System.Net.Http.StringContent( + content: __httpRequestContentBody, + encoding: global::System.Text.Encoding.UTF8, + mediaType: "application/json"); + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUpdateStoreFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + fileIdentifier: fileIdentifier, + request: request); - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUpdateStoreFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStoreFile", + methodName: "UpdateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStoreFile", + methodName: "UpdateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStoreFile", + methodName: "UpdateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUpdateStoreFileResponseContent( + response: __response); + ProcessUpdateStoreFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStoreFile", + methodName: "UpdateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UpdateStoreFile", + methodName: "UpdateStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/{fileIdentifier}\"", + httpMethod: "PATCH", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUpdateStoreFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Update store file metadata
@@ -283,12 +466,14 @@ partial void ProcessUpdateStoreFileResponseContent( /// /// Updated metadata for the file /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UpdateStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.AnyOf fileIdentifier, object? metadata = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.StoreFileMetadataUpdateParams @@ -300,6 +485,7 @@ partial void ProcessUpdateStoreFileResponseContent( storeIdentifier: storeIdentifier, fileIdentifier: fileIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UploadStoreFile.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UploadStoreFile.g.cs index a91b670..6bb29f1 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UploadStoreFile.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.UploadStoreFile.g.cs @@ -14,6 +14,7 @@ public partial class StoresClient { new global::Mixedbread.EndPointAuthorizationRequirement { Type = "Http", + SchemeId = "HttpBearer", Location = "Header", Name = "Bearer", FriendlyName = "Bearer", @@ -57,12 +58,14 @@ partial void ProcessUploadStoreFileResponseContent( /// The ID or name of the store /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UploadStoreFileAsync( global::Mixedbread.AnyOf storeIdentifier, global::Mixedbread.BodyUploadStoreFile request, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { request = request ?? throw new global::System.ArgumentNullException(nameof(request)); @@ -80,22 +83,43 @@ partial void ProcessUploadStoreFileResponseContent( securityRequirements: s_UploadStoreFileSecurityRequirements, operationName: "UploadStoreFileAsync"); - var __pathBuilder = new global::Mixedbread.PathBuilder( - path: $"/v1/stores/{storeIdentifier}/files/upload", - baseUri: HttpClient.BaseAddress); - var __path = __pathBuilder.ToString(); - using var __httpRequest = new global::System.Net.Http.HttpRequestMessage( - method: global::System.Net.Http.HttpMethod.Post, - requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); + using var __timeoutCancellationTokenSource = global::Mixedbread.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::Mixedbread.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::Mixedbread.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: true); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + var __pathBuilder = new global::Mixedbread.PathBuilder( + path: $"/v1/stores/{storeIdentifier}/files/upload", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::Mixedbread.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); #if NET6_0_OR_GREATER - __httpRequest.Version = global::System.Net.HttpVersion.Version11; - __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; #endif foreach (var __authorization in __authorizations) { if (__authorization.Type == "Http" || - __authorization.Type == "OAuth2") + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") { __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( scheme: __authorization.Name, @@ -105,172 +129,331 @@ partial void ProcessUploadStoreFileResponseContent( __authorization.Location == "Header") { __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); - } + } } - using var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent(storeIdentifier.ToString() ?? string.Empty), - name: "\"store_identifier\""); - var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); - __httpRequestContent.Add( - content: __contentFile, - name: "\"file\"", - fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); - if (__contentFile.Headers.ContentDisposition != null) - { - __contentFile.Headers.ContentDisposition.FileNameStar = null; - } - if (request.Params != default) - { + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(storeIdentifier.ToString() ?? string.Empty), + name: "\"store_identifier\""); + var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + if (request.Params != default) + { - __httpRequestContent.Add( - content: new global::System.Net.Http.StringContent($"{request.Params}"), - name: "\"params\""); - } - __httpRequest.Content = __httpRequestContent; + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"{request.Params}"), + name: "\"params\""); + } + __httpRequest.Content = __httpRequestContent; + global::Mixedbread.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); - PrepareRequest( - client: HttpClient, - request: __httpRequest); - PrepareUploadStoreFileRequest( - httpClient: HttpClient, - httpRequestMessage: __httpRequest, - storeIdentifier: storeIdentifier, - request: request); + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareUploadStoreFileRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + storeIdentifier: storeIdentifier, + request: request); - using var __response = await HttpClient.SendAsync( - request: __httpRequest, - completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, - cancellationToken: cancellationToken).ConfigureAwait(false); + return __httpRequest; + } - ProcessResponse( - client: HttpClient, - response: __response); - ProcessUploadStoreFileResponse( - httpClient: HttpClient, - httpResponseMessage: __response); - // Validation Error - if ((int)__response.StatusCode == 422) + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try { - string? __content_422 = null; - global::System.Exception? __exception_422 = null; - global::Mixedbread.HTTPValidationError? __value_422 = null; - try + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) { - if (ReadResponseAsString) + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadStoreFile", + methodName: "UploadStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/upload\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); } - else + catch (global::System.Net.Http.HttpRequestException __exception) { - __content_422 = await __response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadStoreFile", + methodName: "UploadStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/upload\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } - __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; } + + if (__response != null && + __attempt < __maxAttempts && + global::Mixedbread.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadStoreFile", + methodName: "UploadStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/upload\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::Mixedbread.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; } - catch (global::System.Exception __ex) + + if (__response == null) { - __exception_422 = __ex; + throw new global::System.InvalidOperationException("No response received."); } - throw new global::Mixedbread.ApiException( - message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, - innerException: __exception_422, - statusCode: __response.StatusCode) + using (__response) { - ResponseBody = __content_422, - ResponseObject = __value_422, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; - } - - if (ReadResponseAsString) - { - var __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - ProcessResponseContent( + ProcessResponse( client: HttpClient, - response: __response, - content: ref __content); - ProcessUploadStoreFileResponseContent( + response: __response); + ProcessUploadStoreFileResponse( httpClient: HttpClient, - httpResponseMessage: __response, - content: ref __content); - - try + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) { - __response.EnsureSuccessStatusCode(); - - return - global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? - throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadStoreFile", + methodName: "UploadStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/upload\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - catch (global::System.Exception __ex) + else { - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; + await global::Mixedbread.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::Mixedbread.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "UploadStoreFile", + methodName: "UploadStoreFileAsync", + pathTemplate: "$\"/v1/stores/{storeIdentifier}/files/upload\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } - } - else - { - try - { - __response.EnsureSuccessStatusCode(); - using var __content = await __response.Content.ReadAsStreamAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); + // Validation Error + if ((int)__response.StatusCode == 422) + { + string? __content_422 = null; + global::System.Exception? __exception_422 = null; + global::Mixedbread.HTTPValidationError? __value_422 = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + else + { + __content_422 = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); - return - await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? - throw new global::System.InvalidOperationException("Response deserialization failed."); - } - catch (global::System.Exception __ex) - { - string? __content = null; - try - { - __content = await __response.Content.ReadAsStringAsync( -#if NET5_0_OR_GREATER - cancellationToken -#endif - ).ConfigureAwait(false); - } - catch (global::System.Exception) - { - } + __value_422 = global::Mixedbread.HTTPValidationError.FromJson(__content_422, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_422 = __ex; + } + + throw new global::Mixedbread.ApiException( + message: __content_422 ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_422, + statusCode: __response.StatusCode) + { + ResponseBody = __content_422, + ResponseObject = __value_422, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessUploadStoreFileResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::Mixedbread.StoreFile.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::Mixedbread.StoreFile.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::Mixedbread.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } - throw new global::Mixedbread.ApiException( - message: __content ?? __response.ReasonPhrase ?? string.Empty, - innerException: __ex, - statusCode: __response.StatusCode) - { - ResponseBody = __content, - ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( - __response.Headers, - h => h.Key, - h => h.Value), - }; } } + finally + { + __httpRequest?.Dispose(); + } } /// /// Upload file via form to store
@@ -293,6 +476,7 @@ partial void ProcessUploadStoreFileResponseContent( /// The file to upload and index /// /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// public async global::System.Threading.Tasks.Task UploadStoreFileAsync( @@ -300,6 +484,7 @@ partial void ProcessUploadStoreFileResponseContent( byte[] file, string filename, string? @params = default, + global::Mixedbread.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) { var __request = new global::Mixedbread.BodyUploadStoreFile @@ -312,6 +497,7 @@ partial void ProcessUploadStoreFileResponseContent( return await UploadStoreFileAsync( storeIdentifier: storeIdentifier, request: __request, + requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } } diff --git a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.g.cs b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.g.cs index 7fdfde9..ea1d69f 100644 --- a/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.g.cs +++ b/src/libs/Mixedbread/Generated/Mixedbread.StoresClient.g.cs @@ -30,6 +30,9 @@ public sealed partial class StoresClient : global::Mixedbread.IStoresClient, glo #if DEBUG = true; #endif + + /// + public global::Mixedbread.AutoSDKClientOptions Options { get; } /// /// /// @@ -49,11 +52,37 @@ public StoresClient( global::System.Net.Http.HttpClient? httpClient = null, global::System.Uri? baseUri = null, global::System.Collections.Generic.List? authorizations = null, + bool disposeHttpClient = true) : this( + httpClient, + baseUri, + authorizations, + options: null, + disposeHttpClient: disposeHttpClient) + { + } + + /// + /// Creates a new instance of the StoresClient. + /// If no httpClient is provided, a new one will be created. + /// If no baseUri is provided, the default baseUri from OpenAPI spec will be used. + /// + /// The HttpClient instance. If not provided, a new one will be created. + /// The base URL for the API. If not provided, the default baseUri from OpenAPI spec will be used. + /// The authorizations to use for the requests. + /// Client-wide request defaults such as headers, query parameters, retries, and timeout. + /// Dispose the HttpClient when the instance is disposed. True by default. + public StoresClient( + global::System.Net.Http.HttpClient? httpClient = null, + global::System.Uri? baseUri = null, + global::System.Collections.Generic.List? authorizations = null, + global::Mixedbread.AutoSDKClientOptions? options = null, bool disposeHttpClient = true) { + HttpClient = httpClient ?? new global::System.Net.Http.HttpClient(); HttpClient.BaseAddress ??= baseUri ?? new global::System.Uri(DefaultBaseUrl); Authorizations = authorizations ?? new global::System.Collections.Generic.List(); + Options = options ?? new global::Mixedbread.AutoSDKClientOptions(); _disposeHttpClient = disposeHttpClient; Initialized(HttpClient);